local extension = Package("wdtx")
local extension_card = Package:new("wdtx_cards", Package.CardPack)
extension_card.extensionName = "wdtx"
extension_card.game_modes_whitelist = {"wdtx_mode"}

-------------------修改全局---------------------------
-------------------修改全局---------------------------
Fk.skills["#vine_skill"].triggerable = function(self, event, target, player, data)
  if event == fk.DamageInflicted then
    return target == player and player:hasSkill(self) and
      data.damageType == fk.FireDamage
  end
  local effect = data ---@type CardEffectEvent
  return player.id == effect.to and player:hasSkill(self) and
    ((effect.card.name == "slash" or effect.card.name == "wdtx__slash") or effect.card.trueName == "savage_assault" or
    effect.card.trueName == "archery_attack")
end

Fk.skills["ex__leiji"].triggerable = function(self, event, target, player, data)
  return player:hasSkill(self) and target == player and data.card.trueName == "jink" and #player.room.alive_players > 1
end
Fk.skills["longdan"].cardFilter = function(self, to_select, selected)
  if #selected == 1 then return false end
  local _c = Fk:getCardById(to_select)
  local c
  if _c.trueName == "slash" then
    c = Fk:cloneCard("jink")
  elseif _c.trueName == "jink" then
    c = Fk:cloneCard("slash")
  else
    return false
  end
  return (Fk.currentResponsePattern == nil and Self:canUse(c)) or (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(c))
end
Fk.skills["longdan"].viewAs = function(self, cards)
  if #cards ~= 1 then
    return nil
  end
  local _c = Fk:getCardById(cards[1])
  local c
  if _c.trueName == "slash" then
    c = Fk:cloneCard("jink")
  elseif _c.trueName == "jink" then
    c = Fk:cloneCard("slash")
  end
  c.skillName = self.name
  c:addSubcard(cards[1])
  return c
end
-------------------修改全局---------------------------
-------------------修改全局---------------------------
Fk:loadTranslationTable{
    ["wdtx"] = "问鼎天下",
    ["wd"] = "问鼎",
    ["wdtx_cards"] = "问鼎天下卡组",
}

local wumingshi = General(extension, "wumingshi", "qun", 5)
Fk:loadTranslationTable{
  ["wumingshi"] = "无名氏",
  ["#wumingshi"] = "未知",
  ["~wumingshi"] = "",
}
local U = require "packages/utility/utility"
local WU = require "packages/wdtx/WUltiity"

--黄巾刀兵
local hj_daobing = General(extension, "hj_daobing", "qun", 3)
local hj_daofa = fk.CreateTargetModSkill{
  name = "hj_daofa",
  residue_func = function(self, player, skill, scope)
    if player:hasSkill(self) and skill.trueName == "slash_skill" then
      return 1
    end
  end,
}
local hj_silue = fk.CreateTriggerSkill{
  name = "hj_silue",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.Damage},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and
      data.to ~= player and not data.to.dead and not data.to:isNude()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askForCardChosen(player, data.to, "he", self.name)
    if cards then
      room:obtainCard(player, cards, true, fk.ReasonPrey, player.id, self.name)
    end
  end,
}
local hj_tiandao = fk.CreateTriggerSkill{
  name = "hj_tiandao",
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.TurnStart},
  can_trigger = function (self, event, target, player, data)  
    return player:hasSkill(self) and player == target
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local judge = {
      who = player,
      reason = self.name,
    }
    room:judge(judge)
    if not judge.card then return end
    if judge.card.color == Card.Red then
      if #player.player_cards[Player.Hand] == 0 or not player:isWounded() then return end
      local cids = room:askForDiscard(player,1,1,false,self.name,true,".|.|".."heat,diamond".."|.|.|.")
      if cids and #cids > 0 then 
        room:recover({
          who = player,
          num = 1,
          recoverBy = player,
          skillName = self.name
        }) 
      end
    else
      room:obtainCard(player, judge.card, true, fk.ReasonJustMove, player.id, self.name)
      room:loseHp(player,1,self.name)
    end
  end,
}
hj_daobing:addSkill(hj_daofa)
hj_daobing:addSkill(hj_silue)
hj_daobing:addSkill(hj_tiandao)
Fk:loadTranslationTable{
  ["hj_daobing"] = "黄巾刀兵",
  ["hj_daofa"] = "刀法",
  [":hj_daofa"] = "锁定技，出牌阶段你使用杀次数+1",
  ["hj_silue"] = "肆掠",
  [":hj_silue"] = "锁定技，每回合限一次，你对一名其他角色造成伤害后，你可以获得其1张牌",
  ["hj_tiandao"] = "天道",
  [":hj_tiandao"] = "锁定技，你的回合开始时，你进行一次判定，若判定牌为红色你可以弃1张红色手牌回复1点体力否则获得此判定牌然后失去1点体力",

}

local putEquipHandle = function (who,type,id,proposer,skiname)
  local room = who.room
  local eid = who:getEquipment(type)
  room:moveCards({
    from = who.id,
    ids = {id},
    toArea = Card.Processing,
    moveReason = fk.ReasonJustMove,
    proposer = who.id,
    skillName = skiname,
})
  local move3 = {
    ids = {id},
    fromArea = Card.Processing,
    to = who.id,
    toArea = Card.PlayerEquip,
    moveReason = fk.ReasonJustMove,
    proposer = proposer or who.id,
    skillName = skiname,
  }
  
  if eid ~= nil then
    local move2 = {
      ids = {eid},
      from = who.id,
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonJustMove,
    }
    room:moveCards(move2, move3)
  else
    room:moveCards(move3)
  end
end

local wm_guanyu = General(extension, "wm_guanyu", "qun", 4)
local wm_daowu = fk.CreateTriggerSkill{
  name = "wm_daowu",
  priority = 10,
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.RoundStart,fk.CardEffectCancelledOut,fk.TargetSpecifying,fk.TurnEnd},
  can_trigger = function (self, event, target, player, data)  
    if not player:hasSkill(self) then return end
    if event == fk.RoundStart then
      return not player:getEquipment(Card.SubtypeWeapon) or Fk:getCardById(player:getEquipment(Card.SubtypeWeapon)).name ~= "blade"
    elseif event == fk.CardEffectCancelledOut then
      return data.from == player.id and data.card.trueName == "slash"
    elseif event == fk.TargetSpecifying then
      return target == player and not player.dead and data.card.trueName == "slash" and player:getMark("daowu_extra-turn") > 0 and #U.getUseExtraTargets(player.room, data) > 0
    end    
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.RoundStart then
      local totalcards = room.totalcards or Fk:getAllCardIds()
      for _, id in ipairs(totalcards) do
        local card = Fk:getCardById(id, true)
        if card.name == "blade" then
          local area = room:getCardArea(card.id)
          if area == Player.Hand or area == Player.Equip or area == Player.Special then
            room:obtainCard(player.id,id,true,fk.ReasonJustMove)
            putEquipHandle(player,Card.SubtypeWeapon,id,player.id,self.name)
          else
            putEquipHandle(player,Card.SubtypeWeapon,id,player.id,self.name)
          end
          break
        end
      end
    elseif event == fk.CardEffectCancelledOut then
      room:addPlayerMark(player,"daowu_extra-turn",1)
    elseif event == fk.TargetSpecifying then
      local targets = U.getUseExtraTargets(room, data)
      if #targets == 0 then return false end
      local tars = player:getMark("daowu_extra-turn")
      local tos = room:askForChoosePlayers(player, targets, 1, tars, "#wm_daowu-choose:::"..data.card:toLogString()..":"..tars, self.name, true)
      if #tos > 0 then
        table.forEach(tos, function (id)
          TargetGroup:pushTargets(data.targetGroup, id)
        end)
      end
    end
  end,
}
local wm_fenzhan = fk.CreateTriggerSkill{
  name = "wm_fenzhan",
--   anim_type = "control",
  priority = 9,
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart,fk.DamageInflicted,fk.CardEffectCancelledOut,fk.Death},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return end
    if event == fk.EventPhaseStart then
      return target == player and player.phase == Player.Play 
    elseif event == fk.DamageInflicted then
      return data.from and data.from == player and not data.to:isNude() and data.card and data.card:getMark("@@fenzhan_slash-phase") == 1
    elseif event == fk.CardEffectCancelledOut then
      return data.from and data.from == player.id and data.card.trueName == "slash" and not player:isNude() and data.card:getMark("@@fenzhan_slash-phase") == 1
    elseif event == fk.Death then
      return target ~= player and data.damage and data.damage.from and data.damage.from == player and data.damage.card and data.damage.card:getMark("@@fenzhan_slash-phase") == 1
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      local slash 
      local needname,cardmark = "slash","@@fenzhan_slash-phase"
      for _, cid in ipairs(room.draw_pile) do
        local card = Fk:getCardById(cid)
        if card.trueName == needname then slash = card break end
      end
      if not slash then
        for _, cid in ipairs(room.discard_pile) do
          local card = Fk:getCardById(cid)
          if card.trueName == needname then slash = card break end
        end
      end
      if slash then
        room:setCardMark(slash,cardmark,1)
        room:obtainCard(player, slash, true, fk.ReasonJustMove)
      end
    elseif event == fk.DamageInflicted then
      local cards = room:askForCardChosen(player, data.to, "he", self.name)
      if cards then
        room:throwCard(cards, self.name, data.to, player)
      end
    elseif event == fk.CardEffectCancelledOut then
      local cards = player:getCardIds("he")
      local throwid = table.random(cards)
      room:throwCard(throwid, self.name, player, player)
    elseif event == fk.Death then
      local getcards = {0,0,0}
      for _, cid in ipairs(room.draw_pile) do
        local card = Fk:getCardById(cid)
        if getcards[1] == 0 and card.type == Card.TypeBasic and not card.is_damage_card then getcards[1] = cid end
        if getcards[2] == 0 and card.type == Card.TypeTrick and card.is_damage_card then getcards[2] = cid end
        if getcards[3] == 0 and card.type == Card.TypeEquip then getcards[3] = cid end
      end
      if getcards[1] == 0 or getcards[2] == 0 or getcards[3] == 0 then
        for _, cid in ipairs(room.discard_pile) do
          local card = Fk:getCardById(cid)
          if getcards[1] == 0 and card.type == Card.TypeBasic and not card.is_damage_card then getcards[1] = cid end
          if getcards[2] == 0 and card.type == Card.TypeTrick and card.is_damage_card then getcards[2] = cid end
          if getcards[3] == 0 and card.type == Card.TypeEquip then getcards[3] = cid end
        end
      end
      if #getcards > 0 then
        room:obtainCard(player, getcards, true, fk.ReasonJustMove)
      end      
    end
  end,
}
local wm_fenzhan_mod = fk.CreateTargetModSkill{
  name = "#wm_fenzhan_mod",
  bypass_times = function(self, player, skill, scope, card, to)
    return player:hasSkill(wm_fenzhan) and card:getMark("@@fenzhan_slash-phase") == 1
  end
}
wm_fenzhan:addRelatedSkill(wm_fenzhan_mod)
wm_guanyu:addSkill(wm_daowu)
wm_guanyu:addSkill(wm_fenzhan)
-- wm_guanyu:addSkill("rende")
-- wm_guanyu:addSkill("damage_maker")
Fk:loadTranslationTable{
  ["wm_guanyu"] = "关羽",
  ["wm_daowu"] = "刀武",
  ["#wm_daowu-choose"] = "刀武：你可以为%arg增加至多%arg2个目标",
  [":wm_daowu"] = "锁定技，每轮开始，把专属武器【青龙偃月刀】置入武器栏。你使用杀被抵消，本回合内你的下一张杀指向目标+1",
  ["wm_fenzhan"] = "奋战",
  ["@@fenzhan_slash-phase"] = "奋战",
  ["#wm_fenzhan_mod"] = "奋战",
  [":wm_fenzhan"] = "锁定技，出牌阶段开始，你从牌堆获得一张不计入次数的杀。若使用此杀被抵消随机丢弃自己1张牌，否则弃其1张牌。此杀造成死亡，从牌堆获得伤害锦囊牌，非伤害基本牌，装备牌各一张。",
}

local wm_zhangfei = General(extension, "wm_zhangfei", "qun", 4)
local wm_xiongmeng = fk.CreateTriggerSkill{
  name = "wm_xiongmeng",
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    -- data.additionalEffect = (data.additionalEffect or 0) + 1
    if player:usedCardTimes("slash",Player.HistoryPhase) == 1 then
      data.disresponsive = true
    else
      data.additionalDamage = (data.additionalDamage or 0) + 1
    end
  end,
}
wm_zhangfei:addSkill(wm_xiongmeng)
wm_zhangfei:addSkill("wm_fenzhan")
Fk:loadTranslationTable{
  ["wm_zhangfei"] = "张飞",
  ["wm_xiongmeng"] = "雄猛",
  [":wm_xiongmeng"] = "锁定技，你于回合内使用第一张杀指向目标无法被响应，使用除第一张的杀指向目标伤害+1",
}

local story_savegz_skill = fk.CreateTriggerSkill{
  name = "#story_savegz_skill",
  -- anim_type = "drawcard",
  frequency = Skill.Compulsory,
  -- visible = false,
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.room.logic.Wdtx
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local Wdtx = room.logic.Wdtx
    for i, pr in ipairs(room.players) do
      if pr:hasSkill(self) then
        room:handleAddLoseSkills(pr, "-"..self.name, nil, false)
      end
    end
    room:setTag("savegz",player.id)
    local curinfo = Wdtx.storyobj:getCurInfo()
    Wdtx.storyobj:setCurInfo({startpos = curinfo.startpos,selchcinx = 1})
    Wdtx:continueStory(curinfo.startpos,1)
  end
}
Fk:addSkill(story_savegz_skill)
Fk:loadTranslationTable{
  ["#story_savegz_skill"] = "",
}

local hj_gongshou = General(extension, "hj_gongshou", "qun", 4)
local hj_gongshi = fk.CreateTriggerSkill{
  name = "hj_gongshi",
  anim_type = "support",
  priority = 2,
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and not player.dead and data.card.trueName == "slash" and player == target and math.random() < 0.5
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.additionalDamage = (data.additionalDamage or 0) + 1
    -- local targets = U.getUseExtraTargets(room, data)
    -- if #targets == 0 then return false end
    -- local tars = #table.filter(player.player_cards[Player.Hand],function(cid) return Fk:getCardById(cid).trueName == "slash" end)
    -- local tos = room:askForChoosePlayers(player, targets, 1, tars, nil, self.name, true)
    -- if #tos > 0 then
    --   table.forEach(tos, function (id)
    --     TargetGroup:pushTargets(data.targetGroup, id)
    --   end)
    -- end
  end,
}
local gongshi_atkrange = fk.CreateAttackRangeSkill {
  name = "#gongshi_atkrange",
  frequency = Skill.Compulsory,
  correct_func = function(self, from, to)
    if from:hasSkill(hj_gongshi) then
      return 5
    end
  end,
} 
hj_gongshi:addRelatedSkill(gongshi_atkrange)

-- local hj_qingzhuang = fk.CreateTriggerSkill{
--   name = "hj_qingzhuang",
--   anim_type = "support",
--   frequency = Skill.Compulsory,
--   events = {fk.EventPhaseStart},
--   can_trigger = function(self, event, target, player, data)
--     return player:hasSkill(self) and target == player and player.phase == Player.Play and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and table.find(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeEquip end)
--   end,
--   on_use = function(self, event, target, player, data)
--     local room = player.room
--     local equips = table.filter(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeEquip end)
--     local discs = math.ceil(#equips * 1.5)
--     room:throwCard(equips, self.name, player, player)
--     WU:checkCards(player,".|.|.|.|.|^equip",discs)
--   end,
-- }
hj_gongshou:addSkill(hj_gongshi)
-- hj_gongshou:addSkill(hj_qingzhuang)
hj_gongshou:addSkill("hj_tiandao")
Fk:loadTranslationTable{
  ["hj_gongshou"] = "黄巾弓手",
  ["hj_gongshi"] = "灵矢",
  [":hj_gongshi"] = "锁定技，你的攻击范围+5。你使用杀指向目标时。有50%概率伤害+1",
  -- ["hj_qingzhuang"] = "轻装",
  -- [":hj_qingzhuang"] = "锁定技，出牌阶段开始时若你有装备牌，弃掉所有装备牌然后检索牌堆x张非装备牌（x为弃掉装备牌数*1.5向上取整）",
}

local hj_daoqibing = General(extension, "hj_daoqibing", "qun", 4)
local hj_lieqi = fk.CreateTriggerSkill{
  name = "hj_lieqi",
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart,fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) or target ~= player then return end
    if event == fk.EventPhaseStart then
      return player.phase == Player.Play and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and table.find(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeTrick end)
    else
      return data.card.trueName == "slash" and player:distanceTo(player.room:getPlayerById(data.to)) == 1
    end   
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      local tricks = table.filter(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeTrick end)
      local discs = math.ceil(#tricks * 1.5)
      room:throwCard(tricks, self.name, player, player)
      WU:checkCards(player,".|.|.|.|.|^trick",discs)
    else
      data.disresponsive = true
    end    
  end,
}
local hj_lieqi_dis = fk.CreateDistanceSkill{
  name = "#hj_lieqi_dis",
  correct_func = function(self, from, to)
    if from:hasSkill(hj_lieqi) then
      return -1
    end
  end,
}
hj_lieqi:addRelatedSkill(hj_lieqi_dis)
hj_daoqibing:addSkill(hj_lieqi)
-- hj_daoqibing:addSkill("hj_daofa")
hj_daoqibing:addSkill("hj_tiandao")
Fk:loadTranslationTable{
  ["hj_daoqibing"] = "黄巾骑兵",
  ["#hj_lieqi_dis"] = "烈骑",
  ["hj_lieqi"] = "烈骑",
  [":hj_lieqi"] = "锁定技，你与其他角色的距离-1。你使用【杀】指向距离为1的目标时不可被响应。出牌阶段开始时若你有锦囊牌，弃掉所有锦囊牌然后检索牌堆x张非锦囊牌（x为弃掉锦囊牌数*1.5向上取整）",
}

local shanzei_boss = General(extension, "shanzei_boss", "qun", 7)
local shanzei_loulou = General(extension, "shanzei_loulou", "qun", 3)
local sz_shouling = fk.CreateTriggerSkill{
  name = "sz_shouling",
  anim_type = "support",
  priority = 3,
  frequency = Skill.Compulsory,
  events = {fk.TurnStart,fk.DrawNCards,fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    if event == fk.TurnStart then
      return player:hasSkill(self) and target == player 
    elseif event == fk.DrawNCards then
      return player:getMark("@morale") > 2 and target == player 
    else
      return player:getMark("@morale") > 3 and not player.dead and data.from and data.from == player and data.card and data.card.trueName == "slash"
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room  
    if event == fk.TurnStart then
      for _,pr in ipairs(room.alive_players) do
        if string.startsWith(pr.general,"shanzei") then
          room:addPlayerMark(pr,"@morale")  
        end
      end
      local others = room:getOtherPlayers(player,false,true)
      if #others == 0 then return end
      local deadplayer = table.find(others,function(pr) return pr.dead end)
      if deadplayer then
        room:changeHero(deadplayer, "shanzei_loulou", true, false, true)
        room:revivePlayer(deadplayer, false)
        room:askForChooseKingdom({deadplayer})
        -- if deadplayer.role ~= "rebel" then
        --   room:setPlayerProperty(deadplayer, "role", "rebel")
        -- end
        room:drawCards(deadplayer, 4,self.name)
      end
    elseif event == fk.DrawNCards then
      data.n = data.n + 1 
    else
      data.damage = data.damage + 1
    end
  end,
}
local moralMaxMod = fk.CreateMaxCardsSkill{
  name = "#moralMaxMod",
  frequency = Skill.Compulsory,
  correct_func = function (self, player)
    if player:getMark("@morale") > 0 then
      return 1
    end
  end,
}
local moralTargetmod = fk.CreateTargetModSkill{
  name = "#moralTargetmod",
  frequency = Skill.Compulsory,
  residue_func = function(self, player, skill, scope)
    if player:getMark("@morale") > 1 and skill.trueName == "slash_skill" then
      return 1
    end
  end,
}
sz_shouling:addRelatedSkill(moralMaxMod)
sz_shouling:addRelatedSkill(moralTargetmod)
shanzei_boss:addSkill(sz_shouling)
shanzei_loulou:addSkill("hj_silue")
Fk:loadTranslationTable{
  ["shanzei_boss"] = "山贼首领",
  ["shanzei_loulou"] = "山贼",
  ["@morale"] = "士气+",
  ["#moralMaxMod"] = "士气",
  ["#moralTargetmod"] = "士气",
  ["sz_shouling"] = "首领",
  [":sz_shouling"] = "锁定技，你的回合开始，复活一名山贼。所有山贼获得1层“士气”标记。每当角色有1层此标记。手牌上限+1，2层回合内使用【杀】次数+1，3层摸牌阶段多摸1张，4层使用【杀】造成伤害+1。",
}
---------------------------------------------------------定义卡组-----------------------------------------------------------------
---------------------------------------------------------定义卡组-----------------------------------------------------------------
---------------------------------------------------------定义卡组-----------------------------------------------------------------
--护甲
local clone_ex_nihilo = Fk:cloneCard("ex_nihilo")
local clone_slash = Fk:cloneCard("slash")
local defshieldSkill = fk.CreateActiveSkill{
  name = "defshield_skill",
  prompt = "#defshield_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = clone_ex_nihilo.skill.canUse,
  on_use = clone_ex_nihilo.skill.onUse,
  on_effect = function(self, room, effect)
    local target = room:getPlayerById(effect.to)
    if target.dead then return end
    -- local extra_add = fhjdExtraAdd(room,effect.card,"@up_defmark")
    target.shield = target.shield + 1 
    room:broadcastProperty(target, "shield")
  end
}
local defShield = fk.CreateBasicCard{
  name = "defshield",
  suit = Card.Diamond,
  number = 1,
  skill = defshieldSkill,
}
extension_card:addCards({
  defShield,
})
Fk:loadTranslationTable {
  ["defshield"] = "护甲",
  [":defshield"] = "基本牌牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：获得+1护甲",
  ["#defshield_skill"] = "获得1护甲",
}
--此模式新的杀
local wdtxSlashSkill = fk.CreateActiveSkill{
  name = "wdtx__slash_skill",
  prompt = function(self, selected_cards)
    local card = Fk:cloneCard("wdtx__slash")
    card.subcards = Card:getIdList(selected_cards)
    local max_num = self:getMaxTargetNum(Self, card)
    if max_num > 1 then
      local num = #table.filter(Fk:currentRoom().alive_players, function (p)
        return p ~= Self and not Self:isProhibited(p, card)
      end)
      max_num = math.min(num, max_num)
    end
    card.subcards = {}
    return max_num > 1 and "#wdtx__slash_skill_multi:::" .. max_num or "#wdtx__slash_skill"
  end,
  max_phase_use_time = 1,
  target_num = 1,
  can_use = clone_slash.skill.canUse,
  mod_target_filter = clone_slash.skill.modTargetFilter,
  target_filter = clone_slash.skill.targetFilter,
  on_effect = function(self, room, effect)
    local extra_add = 0
    if room.logic.class.name == "wdtx_logic" then 
      extra_add = effect.card:getMark("@up_damage")
    end
    local from = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.to)
    if not to.dead then
      room:damage({
        from = from,
        to = to,
        card = effect.card,
        damage = 1 + extra_add,
        damageType = fk.NormalDamage,
        skillName = self.name
      })
    end
  end
}
local wdtx_Slash = fk.CreateBasicCard{
  name = "wdtx__slash",
  skill = wdtxSlashSkill,
  suit = Card.Spade,
  number = 8,
  is_damage_card = true,
}
extension_card:addCards{
  wdtx_Slash,
}
Fk:loadTranslationTable{
  ["wdtx__slash"] = "杀",
  ["wdtx__slash_skill"] = "对目标角色造成1点伤害（限定问鼎天下模式有效）",
	[":wdtx__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成1点伤害（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：此卡伤害效果额外增加X（X为等级数）</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1</font>"..
  "<br /><font color='#90EE90'>等级3：继承等级1</font>",
  ["#wdtx__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点伤害",
  ["#wdtx__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点伤害",
}
--新的雷杀
local wdtx_thunderSlashSkill = fk.CreateActiveSkill{
  name = "wdtx_thunder__slash_skill",
  prompt = function(self, selected_cards)
    local card = Fk:cloneCard("wdtx_thunder__slash")
    card.subcards = Card:getIdList(selected_cards)
    local max_num = self:getMaxTargetNum(Self, card)
    if max_num > 1 then
      local num = #table.filter(Fk:currentRoom().alive_players, function (p)
        return p ~= Self and not Self:isProhibited(p, card)
      end)
      max_num = math.min(num, max_num)
    end
    card.subcards = {}
    return max_num > 1 and "#wdtx_thunder__slash_skill_multi:::" .. max_num or "#wdtx_thunder__slash_skill"
  end,
  max_phase_use_time = 1,
  target_num = 1,
  can_use = clone_slash.skill.canUse,
  mod_target_filter = clone_slash.skill.modTargetFilter,
  target_filter = clone_slash.skill.targetFilter,
  on_effect = function(self, room, effect)
    local extra_add = 0
    if room.logic.class.name == "wdtx_logic" then 
      extra_add = effect.card:getMark("@up_damage")
    end
    local from = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.to)
    if not to.dead then
      room:damage({
        from = from,
        to = to,
        card = effect.card,
        damage = 1 + extra_add,
        damageType = fk.ThunderDamage,
        skillName = self.name
      })
    end
  end
}
local wdtx_thunderSlash = fk.CreateBasicCard{
  name = "wdtx_thunder__slash",
  skill = wdtx_thunderSlashSkill,
  suit = Card.Spade,
  number = 8,
  is_damage_card = true,
}
extension_card:addCards{
  wdtx_thunderSlash,
}
Fk:loadTranslationTable{
  ["wdtx_thunder__slash"] = "雷杀",
  ["wdtx_thunder__slash_skill"] = "对目标角色造成1点雷属性伤害（限定问鼎天下模式有效）",
	[":wdtx_thunder__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成1点雷属性伤害（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：此卡伤害效果额外增加X（X为等级数）</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1</font>"..
  "<br /><font color='#90EE90'>等级3：继承等级1</font>",
  ["#wdtx_thunder__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点雷属性伤害",
  ["#wdtx_thunder__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点雷属性伤害",
}
--新的火杀
local wdtx_fireSlashSkill = fk.CreateActiveSkill{
  name = "wdtx_fire__slash_skill",
  prompt = function(self, selected_cards)
    local card = Fk:cloneCard("wdtx_fire__slash")
    card.subcards = Card:getIdList(selected_cards)
    local max_num = self:getMaxTargetNum(Self, card)
    if max_num > 1 then
      local num = #table.filter(Fk:currentRoom().alive_players, function (p)
        return p ~= Self and not Self:isProhibited(p, card)
      end)
      max_num = math.min(num, max_num)
    end
    card.subcards = {}
    return max_num > 1 and "#wdtx_fire__slash_skill_multi:::" .. max_num or "#wdtx_fire__slash_skill"
  end,
  max_phase_use_time = 1,
  target_num = 1,
  can_use = clone_slash.skill.canUse,
  mod_target_filter = clone_slash.skill.modTargetFilter,
  target_filter = clone_slash.skill.targetFilter,
  on_effect = function(self, room, effect)
    local extra_add = 0
    if room.logic.class.name == "wdtx_logic" then 
      extra_add = effect.card:getMark("@up_damage")
    end
    local from = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.to)
    if not to.dead then
      room:damage({
        from = from,
        to = to,
        card = effect.card,
        damage = 1 + extra_add,
        damageType = fk.FireDamage,
        skillName = self.name
      })
    end
  end
}
local wdtx_fireSlash = fk.CreateBasicCard{
  name = "wdtx_fire__slash",
  skill = wdtx_fireSlashSkill,
  suit = Card.Spade,
  number = 8,
  is_damage_card = true,
}
extension_card:addCards{
  wdtx_fireSlash,
}
Fk:loadTranslationTable{
  ["wdtx_fire__slash"] = "火杀",
  ["wdtx_fire__slash_skill"] = "对目标角色造成1点火属性伤害（限定问鼎天下模式有效）",
	[":wdtx_fire__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成1点火属性伤害（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：此卡伤害效果额外增加X（X为等级数）</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1</font>"..
  "<br /><font color='#90EE90'>等级3：继承等级1</font>",
  ["#wdtx_fire__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点火属性伤害",
  ["#wdtx_fire__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点火属性伤害",
}

local wdtx__jink_skill = fk.CreateActiveSkill{
  name = "wdtx__jink_skill",
  can_use = Util.FalseFunc,
  on_effect = function(self, room, effect)
    if effect.responseToEvent then
      effect.responseToEvent.isCancellOut = true
      if room.logic.class.name ~= "wdtx_logic" then return end
      if effect.card and effect.card:getMark("@slash_back") > 0 and effect.responseToEvent and effect.responseToEvent.from then
        room:useVirtualCard("slash", nil, room:getPlayerById(effect.from), {room:getPlayerById(effect.responseToEvent.from)}, self.name, true)
      end      
    end
  end
}
local wdtx__jink = fk.CreateBasicCard{
  name = "wdtx__jink",
  suit = Card.Heart,
  number = 2,
  skill = wdtx__jink_skill,
  is_passive = true,
}
extension_card:addCards{
  wdtx__jink,
}
Fk:loadTranslationTable{
  ["wdtx__jink"] = "闪",
  ["@slash_back"] = "反杀",
  ["wdtx__jink_skill"] = "抵消【杀】的效果",
  [":wdtx__jink"] = "基本牌<br /><b>时机</b>：【杀】对你生效时<br /><b>目标</b>：此【杀】<br /><b>效果</b>：抵消此【杀】的效果。（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：此卡使用效果结算后视为对响应此卡的目标使用【杀】</font>"
}

local wdtx__peach_skill = fk.CreateActiveSkill{
  name = "wdtx__peach_skill",
  prompt = "#wdtx__peach_skill",
  mod_target_filter = function(self, to_select)
    return Fk:currentRoom():getPlayerById(to_select):isWounded() and
      not table.find(Fk:currentRoom().alive_players, function(p)
        return p.dying
      end)
  end,
  can_use = function(self, player, card)
    return player:isWounded() and not player:isProhibited(player, card)
  end,
  on_use = function(self, room, use)
    if not use.tos or #TargetGroup:getRealTargets(use.tos) == 0 then
      use.tos = { { use.from } }
    end
  end,
  on_effect = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.to)
    local extra_add = 0
    if room.logic.class.name == "wdtx_logic" then 
      extra_add = effect.card:getMark("@up_recover")
    end
    if target:isWounded() and not target.dead then
      room:recover({
        who = target,
        num = 1+extra_add,
        card = effect.card,
        recoverBy = player,
        skillName = self.name
      })
    end
  end
}
local wdtx__peach = fk.CreateBasicCard{
  name = "wdtx__peach",
  suit = Card.Heart,
  number = 3,
  skill = wdtx__peach_skill,
}

extension_card:addCards({
  wdtx__peach,
})
Fk:loadTranslationTable{
  ["wdtx__peach"] = "桃",
  ["@up_recover"] = "回复+",
  ["#wdtx__peach_skill"] = "已受伤的你/处于濒死状态的角色<br /><b>效果</b>：目标角色回复1点体力",
  ["wdtx__peach_skill"] = "你回复1点体力",
  [":wdtx__peach"] = "基本牌<br /><b>时机</b>：出牌阶段/一名角色处于濒死状态时<br /><b>目标</b>：已受伤的你/处于濒死状态的角色<br /><b>效果</b>：目标角色回复1点体力。（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：此卡效果额外恢复X（X为等级数）</font>"
}

local wdtx_dismantlementSkill = fk.CreateActiveSkill{
  name = "wdtx__dismantlement_skill",
  prompt = "#wdtx__dismantlement_skill",
  target_num = 1,
  on_use = function(self, room, cardUseEvent)
    local mark = cardUseEvent.card:getMark("@up_dismant")
    if room.logic.class.name == "wdtx_logic" and mark > 0 then
      cardUseEvent.disresponsiveList = cardUseEvent.disresponsiveList or {}
      local targets = room.alive_players
      if #targets > 0 then
        for _, p in ipairs(targets) do
          table.insertIfNeed(cardUseEvent.disresponsiveList, p.id)
        end
      end
    end  
  end,
  mod_target_filter = function(self, to_select, selected, user, card)
    local player = Fk:currentRoom():getPlayerById(to_select)
    return user ~= to_select and not player:isAllNude()
  end,
  target_filter = function(self, to_select, selected, _, card)
    if #selected < self:getMaxTargetNum(Self, card) then
      return self:modTargetFilter(to_select, selected, Self.id, card)
    end
  end,
  on_effect = function(self, room, effect)
    local from = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.to)
    if from.dead or to.dead or to:isAllNude() then return end
    local cid
    if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@up_dismant") > 0 then 
      local extra_add = effect.card:getMark("@up_dismant") + 1
      cid = room:askForCardsChosen(from, to, 1, math.min(extra_add,#to:getCardIds("hej")),"hej",self.name)
    else
      cid = room:askForCardChosen(from, to, "hej", self.name)
    end
    room:throwCard(type(cid) == "number" and {cid} or cid, self.name, to, from)
  end
}
local wdtx__dismantlement = fk.CreateTrickCard{
  name = "wdtx__dismantlement",
  suit = Card.Spade,
  number = 3,
  skill = wdtx_dismantlementSkill,
}

extension_card:addCards({
  wdtx__dismantlement,
})
Fk:loadTranslationTable{
  ["wdtx__dismantlement"] = "过河拆桥",
  ["@up_dismant"] = "拆数+",
  ["#wdtx__dismantlement_skill"] = "选择一名区域内有牌的其他角色，你弃置其区域内的一张牌",
  ["wdtx__dismantlement_skill"] = "过河拆桥",
  [":wdtx__dismantlement"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：一名区域内有牌的其他角色。<br /><b>效果</b>：你弃置目标角色区域内的一张牌。（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：此卡效果额外选择X张牌（X为等级数）</font>"
  -- "<br /><font color='#90EE90'>等级2：继承等级1</font>"
}

local wdtx__snatchSkill = fk.CreateActiveSkill{
  name = "wdtx__snatch_skill",
  prompt = "#wdtx__snatch_skill",
  distance_limit = 1,
  mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
    local player = Fk:currentRoom():getPlayerById(to_select)
    local from = Fk:currentRoom():getPlayerById(user)
    return from ~= player and not (player:isAllNude() or (distance_limited and not self:withinDistanceLimit(from, false, card, player)))
  end,
  target_filter = function(self, to_select, selected, _, card, extra_data)
    local count_distances = not (extra_data and extra_data.bypass_distances)
    if card:getMark("@up_snatch") > 0 then
      count_distances = false
    end
    if #selected < self:getMaxTargetNum(Self, card) then
      return self:modTargetFilter(to_select, selected, Self.id, card, count_distances)
    end
  end,
  target_num = 1,
  on_effect = function(self, room, effect)
    local from = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.to)
    if from.dead or to.dead or to:isAllNude() then return end
    local cid
    if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@up_snatch") > 0 then 
      local extra_add = effect.card:getMark("@up_snatch") + 1
      cid = room:askForCardsChosen(from, to, 1, math.min(extra_add,#to:getCardIds("hej")),"hej",self.name)
    else
      cid = room:askForCardChosen(from, to, "hej", self.name)
    end
    room:obtainCard(from, cid, false, fk.ReasonPrey)
  end
}
local wdtx__snatch = fk.CreateTrickCard{
  name = "wdtx__snatch",
  suit = Card.Spade,
  number = 3,
  skill = wdtx__snatchSkill,
}

extension_card:addCards({
  wdtx__snatch,
})

Fk:loadTranslationTable{
  ["wdtx__snatch"] = "顺手牵羊",
  ["@up_snatch"] = "顺数+",
  ["#wdtx__snatch_skill"] = "选择距离1的区域内有牌的角色，你获得其区域内的一张牌",
  ["wdtx__snatch_skill"] = "顺手牵羊",
  [":wdtx__snatch"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：距离1的一名区域内有牌的角色<br /><b>效果</b>：你获得目标角色区域内的一张牌。（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：此卡效果额外选择X张牌且不受距离影响（X为等级数）</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1</font>"
}

local wdtx__duelSkill = fk.CreateActiveSkill{
  name = "wdtx__duel_skill",
  prompt = "#wdtx__duel_skill",
  mod_target_filter = function(self, to_select, selected, user, card)
    return user ~= to_select
  end,
  target_filter = function(self, to_select, selected, _, card)
    if #selected < self:getMaxTargetNum(Self, card) then
      return self:modTargetFilter(to_select, selected, Self.id, card)
    end
  end,
  target_num = 1,
  on_effect = function(self, room, effect)
    local to = room:getPlayerById(effect.to)
    local from = room:getPlayerById(effect.from)
    local responsers = { to, from }
    local currentTurn = 1
    local currentResponser = to

    while currentResponser:isAlive() do
      local loopTimes = 1
      if effect.fixedResponseTimes then
        local canFix = currentResponser == to
        if effect.fixedAddTimesResponsors then
          canFix = table.contains(effect.fixedAddTimesResponsors, currentResponser.id)
        end
        if canFix then
          if type(effect.fixedResponseTimes) == 'table' then
            loopTimes = effect.fixedResponseTimes["slash"] or 1
          elseif type(effect.fixedResponseTimes) == 'number' then
            loopTimes = effect.fixedResponseTimes
          end
        end
      end
      local cardResponded
      for i = 1, loopTimes do
        cardResponded = room:askForResponse(currentResponser, 'slash', nil, nil, false, nil, effect)
        if cardResponded then
          room:responseCard({
            from = currentResponser.id,
            card = cardResponded,
            responseToEvent = effect,
          })
        else
          break
        end
      end
      if not cardResponded then
        break
      end
      currentTurn = currentTurn % 2 + 1
      currentResponser = responsers[currentTurn]
    end
    if currentResponser:isAlive() then
      if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@slash_reduce") > 0 then 
        room:handleAddLoseSkills(to, "slashReduceSkill", nil, false)
      end
      room:damage({
        from = responsers[currentTurn % 2 + 1],
        to = currentResponser,
        card = effect.card,
        damage = 1,
        damageType = fk.NormalDamage,
        skillName = self.name,
      })
    end
  end
}
local slashReduceSkill = fk.CreateTriggerSkill{
  name = 'slashReduceSkill',
  anim_type = "negative",
  frequency = Skill.Compulsory,
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:handleAddLoseSkills(player, "-slashReduceSkill", nil, false)
  end,
}
local slashReduceModSkill = fk.CreateTargetModSkill{
  name = "#slashReduceModSkill",
  frequency = Skill.Compulsory,
  residue_func = function(self, player, skill, scope)
    if player:hasSkill(self) and skill.trueName == "slash_skill"
      and scope == Player.HistoryPhase then
      return -1
    end
  end,
}
slashReduceSkill:addRelatedSkill(slashReduceModSkill)
Fk:addSkill(slashReduceSkill)
local wdtx__duel = fk.CreateTrickCard{
  name = "wdtx__duel",
  suit = Card.Spade,
  number = 1,
  is_damage_card = true,
  skill = wdtx__duelSkill,
}
extension_card:addCards({
  wdtx__duel,
})
Fk:loadTranslationTable{
  ["wdtx__duel"] = "决斗",
  ["@slash_reduce"] = "杀数-",
  ["slashReduceSkill"] = "怯懦",
  ["#slashReduceModSkill"] = "怯懦",
  [":slashReduceSkill"] = "锁定技，你的回合内使用杀次数-1，你的回合结束后失去此技能。",
  ["#wdtx__duel_skill"] = "选择一名其他角色，由其开始，其与你轮流打出一张【杀】，直到其与你中的一名角色未打出【杀】。<br />未打出【杀】的角色受到其与你中的另一名角色造成的1点伤害(升级后其受到此伤害后获得【怯懦】技能)",
  ["wdtx__duel_skill"] = "决斗",
  [":wdtx__duel"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：一名其他角色<br /><b>效果</b>：由目标角色开始，其与你轮流打出一张【杀】，直到其与你中的一名角色未打出【杀】。未打出【杀】的角色受到其与你中的另一名角色造成的1点伤害。（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：使用此卡造成伤害前。目标角色获得【怯懦】技能。</font>"
}

local wdtx__ex_nihiloSkill = fk.CreateActiveSkill{
  name = "wdtx__ex_nihilo_skill",
  prompt = "#wdtx__ex_nihilo_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
      cardUseEvent.tos = { { cardUseEvent.from } }
    end
  end,
  on_effect = function(self, room, effect)
    local target = room:getPlayerById(effect.to)
    if target.dead then return end
    local extra_add = effect.card:getMark("@up_exNihilo")
    target:drawCards(2+extra_add, "ex_nihilo")
  end
}
local wdtx__ex_nihilo = fk.CreateTrickCard{
  name = "wdtx__ex_nihilo",
  suit = Card.Heart,
  number = 7,
  skill = wdtx__ex_nihiloSkill,
}
extension_card:addCards({
  wdtx__ex_nihilo,
})
Fk:loadTranslationTable{
  ["wdtx__ex_nihilo"] = "无中生有",
  ["@up_exNihilo"] = "再摸+",
  ["#wdtx__ex_nihilo_skill"] = "你摸两张牌",
  ["wdtx__ex_nihilo_skill"] = "无中生有",
  [":wdtx__ex_nihilo"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：你<br /><b>效果</b>：目标角色摸两张牌。（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：额外摸X张牌（X为等级数）。</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1。</font>"
}

local wdtx__nullificationSkill = fk.CreateActiveSkill{
  name = "wdtx__nullification_skill",
  can_use = Util.FalseFunc,
  on_use = function(self,room, effect) 
    if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@@up_nullifi") > 0 then 
      -- local from = room:getPlayerById(effect.from)
      local targets = room.alive_players
      if #targets > 0 then
        effect.disresponsiveList = effect.disresponsiveList or {}
        for _, p in ipairs(targets) do
          table.insertIfNeed(effect.disresponsiveList, p.id)
        end
      end
    end
    room:delay(500)
    if room.current.id < 0 then
      local invokeplayer = table.find(room.alive_players,function(pr) return pr.id > 0 end) or room.alive_players[1]
      room:askForSkillInvoke(invokeplayer, "invokebynulli", nil, "#invokebynulli")
    end
  end,
  on_effect = function(self, room, effect)
    if effect.responseToEvent then
      effect.responseToEvent.isCancellOut = true
      local responfrom = effect.responseToEvent and effect.responseToEvent.from
      if responfrom and responfrom ~= effect.from and room.logic.class.name == "wdtx_logic" and effect.card:getMark("@@up_nullifi") > 0 then 
        local from = room:getPlayerById(responfrom)
        room:setPlayerMark(from,"@@up_nullifi",1)
        room:handleAddLoseSkills(from, "prohTrickCardSkill", nil, false)
      end
    end
  end
}
local prohTrickCardSkill = fk.CreateTriggerSkill{
  name = 'prohTrickCardSkill',
  anim_type = "negative",
  frequency = Skill.Compulsory,
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and player:getMark("@@up_nullifi") > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player,"@@up_nullifi",0)
    room:handleAddLoseSkills(player, "-prohTrickCardSkill", nil, false)
  end,
}
local trick_prohibit = fk.CreateProhibitSkill{
  name = "#trick_prohibit",
  frequency = Skill.Compulsory,
  prohibit_use = function(self, player, card)
    local mark = player:getMark("@@up_nullifi")
    return mark ~= 0 and card.type == Card.TypeTrick
  end,
}
prohTrickCardSkill:addRelatedSkill(trick_prohibit)
Fk:addSkill(prohTrickCardSkill)
local wdtx__nullification = fk.CreateTrickCard{
  name = "wdtx__nullification",
  suit = Card.Spade,
  number = 11,
  skill = wdtx__nullificationSkill,
  is_passive = true,
}

extension_card:addCards({
  wdtx__nullification,
})
Fk:loadTranslationTable{
  ["wdtx__nullification"] = "无懈可击",
  ["prohTrickCardSkill"] = "沉默",
  [":prohTrickCardSkill"] = "锁定技，你不能使用锦囊牌，你的回合结束时失去此技能",
  ["#trick_prohibit"] = "沉默",
  ["@@up_nullifi"] = "沉默",
  ["wdtx__nullification_skill"] = "无懈可击",
  [":wdtx__nullification"] = "锦囊牌<br /><b>时机</b>：锦囊牌对目标角色生效前，或一张【无懈可击】生效前<br /><b>目标</b>：该锦囊牌<br /><b>效果</b>：抵消该锦囊牌对该角色产生的效果，或抵消另一张【无懈可击】产生的效果。（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：使用此卡时不可被响应。且响应目标获得【沉默】技能。</font>"
}

local wdtx__savageAssaultSkill = fk.CreateActiveSkill{
  name = "wdtx__savage_assault_skill",
  prompt = "#wdtx__savage_assault_skill",
  can_use = Util.AoeCanUse,
  on_use = function(self, room, cardUseEvent)
    if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
      cardUseEvent.tos = {}
      local mark = cardUseEvent.card:getMark("@up_easyhurt")
      if mark > 0 then
        cardUseEvent.disresponsiveList = cardUseEvent.disresponsiveList or {}
      end     
      for _, player in ipairs(room:getOtherPlayers(room:getPlayerById(cardUseEvent.from))) do
        if not room:getPlayerById(cardUseEvent.from):isProhibited(player, cardUseEvent.card) then
          TargetGroup:pushTargets(cardUseEvent.tos, player.id)
          if mark > 0 then
            table.insertIfNeed(cardUseEvent.disresponsiveList, player.id)
          end
        end
      end
    end
  end,
  mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
    return user ~= to_select
  end,
  on_effect = function(self, room, effect)
    local cardResponded = room:askForResponse(room:getPlayerById(effect.to), 'slash', nil, nil, false, nil, effect)
    if cardResponded then
      room:responseCard({
        from = effect.to,
        card = cardResponded,
        responseToEvent = effect,
      })
    else
      room:damage({
        from = room:getPlayerById(effect.from),
        to = room:getPlayerById(effect.to),
        card = effect.card,
        damage = 1,
        damageType = fk.NormalDamage,
        skillName = self.name,
      })
      if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@up_easyhurt") > 0 then 
        local to = room:getPlayerById(effect.to)
        room:addPlayerMark(to,"@up_easyhurt",effect.card:getMark("@up_easyhurt") + 1)
        if not to:hasSkill("easyHurtSkill") then
          room:handleAddLoseSkills(to, "easyHurtSkill", nil, false)
        end
      end
    end
  end
}
local easyHurtSkill = fk.CreateTriggerSkill{
  name = 'easyHurtSkill',
  anim_type = "negative",
  frequency = Skill.Compulsory,
  events = {fk.DamageFinished,fk.TurnEnd,fk.EventLoseSkill},
  can_trigger = function(self, event, target, player, data)
    if event == fk.DamageFinished then
      return player:hasSkill(self) and target == player and data.card and not player.dead and player:getMark("@up_easyhurt") > 0
    elseif event == fk.TurnEnd then
      return player:hasSkill(self) and target == player and player:getMark("@up_easyhurt") > 0
    else
      return player == target and data == self and (player:getMark("tatal_damaged") > 0 or player:getMark("@up_easyhurt") > 0)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DamageFinished then
      local tatal_damaged = player:getMark("tatal_damaged")
      local per = 4
      local per_damage = data.damage / per
      local mod_damage = data.damage % per
      per_damage = per_damage > 0 and math.floor(per_damage) or 0
      mod_damage = (mod_damage + tatal_damaged) % per == 0 and 1 or 0
      room:setPlayerMark(player,"tatal_damaged",tatal_damaged+data.damage)
      if per_damage + mod_damage > 0 then
        room:damage({
          to = player,
          damage = per_damage + mod_damage,
          damageType = fk.NormalDamage,
          skillName = self.name
        })
      end
    elseif event == fk.TurnEnd then
      room:removePlayerMark(player,"@up_easyhurt",1)
      local mark = player:getMark("@up_easyhurt")
      if mark <= 0 then
        room:handleAddLoseSkills(player, "-easyHurtSkill", nil, false)
      end
    else
      room:setPlayerMark(player,"tatal_damaged",0)
      room:setPlayerMark(player,"@up_easyhurt",0)
    end  
  end,
}
Fk:addSkill(easyHurtSkill)
local wdtx__savage_assault = fk.CreateTrickCard{
  name = "wdtx__savage_assault",
  suit = Card.Spade,
  number = 7,
  is_damage_card = true,
  multiple_targets = true,
  skill = wdtx__savageAssaultSkill,
}

extension_card:addCards({
  wdtx__savage_assault,
})
Fk:loadTranslationTable{
  ["wdtx__savage_assault"] = "南蛮入侵",
  ["easyHurtSkill"] = "易伤",
  [":easyHurtSkill"] = "锁定技，每当受到共4点的牌伤害会额外受到1点伤害，拥有“易伤”标记的角色在其回合结束时其标记-1，当此标记为0时失去此技能",
  ["@up_easyhurt"] = "易伤+",
  ["#wdtx__savage_assault_skill"] = "所有其他角色需打出一张【杀】，否则受到1点伤害",
  ["wdtx__savage_assault_skill"] = "南蛮入侵",
  [":wdtx__savage_assault"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：所有其他角色<br /><b>效果</b>：每名目标角色需打出一张【杀】，否则受到1点伤害。（升级后此牌在造成伤害结算后该角色获得【易伤】技能，升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：使用此卡不可被响应，受到此牌伤害的目标使其获得【易伤】技能且获得X+1层“易伤”标记。（X为等级数）</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1</font>"
}

local wdtx__archeryAttackSkill = fk.CreateActiveSkill{
  name = "wdtx__archery_attack_skill",
  prompt = "#wdtx__archery_attack_skill",
  can_use = Util.AoeCanUse,
  on_use = function(self, room, cardUseEvent)
    if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
      cardUseEvent.tos = {}
      local mark = cardUseEvent.card:getMark("@up_arrowhurt")
      if mark > 0 then
        cardUseEvent.disresponsiveList = cardUseEvent.disresponsiveList or {}
      end     
      for _, player in ipairs(room:getOtherPlayers(room:getPlayerById(cardUseEvent.from))) do
        if not room:getPlayerById(cardUseEvent.from):isProhibited(player, cardUseEvent.card) then
          TargetGroup:pushTargets(cardUseEvent.tos, player.id)
          if mark > 0 then
            table.insertIfNeed(cardUseEvent.disresponsiveList, player.id)
          end
        end
      end
    end
  end,
  mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
    return user ~= to_select
  end,
  on_effect = function(self, room, effect)
    local cardResponded = room:askForResponse(room:getPlayerById(effect.to), 'jink', nil, nil, false, nil, effect)

    if cardResponded then
      room:responseCard({
        from = effect.to,
        card = cardResponded,
        responseToEvent = effect,
      })
    else
      if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@up_arrowhurt") > 0 then 
        local to = room:getPlayerById(effect.to)
        room:addPlayerMark(to,"@up_arrowhurt",effect.card:getMark("@up_arrowhurt") + 1)
        room:handleAddLoseSkills(to, "arrowHurtSkill", nil, false)
      end
      room:damage({
        from = room:getPlayerById(effect.from),
        to = room:getPlayerById(effect.to),
        card = effect.card,
        damage = 1,
        damageType = fk.NormalDamage,
        skillName = self.name,
      })
    end
  end
}
local arrowHurtSkill = fk.CreateTriggerSkill{
  name = 'arrowHurtSkill',
  anim_type = "negative",
  frequency = Skill.Compulsory,
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and player:getMark("@up_arrowhurt") > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player,"@up_arrowhurt",0)
    room:handleAddLoseSkills(player, "-arrowHurtSkill", nil, false)
    -- local mark = player:getMark("@up_arrowhurt")
    -- room:removePlayerMark(player,"@up_arrowhurt",1)
    -- if mark == 1 then
    --   room:handleAddLoseSkills(player, "-arrowHurtSkill", nil, false)
    -- end
  end,
}
local arrowhurtMaxMod = fk.CreateMaxCardsSkill{
  name = "#arrowhurtMaxMod",
  frequency = Skill.Compulsory,
  correct_func = function (self, player)
    if player:hasSkill(self) and player:getMark("@up_arrowhurt") > 0 then
      return -player:getMark("@up_arrowhurt")
    end
  end,
}
arrowHurtSkill:addRelatedSkill(arrowhurtMaxMod)
Fk:addSkill(arrowHurtSkill)
local wdtx__archery_attack = fk.CreateTrickCard{
  name = "wdtx__archery_attack",
  suit = Card.Heart,
  number = 1,
  is_damage_card = true,
  multiple_targets = true,
  skill = wdtx__archeryAttackSkill,
}
extension_card:addCards({
  wdtx__archery_attack,
})
Fk:loadTranslationTable{
  ["wdtx__archery_attack"] = "万箭齐发",
  ["arrowHurtSkill"] = "箭伤",
  ["#arrowhurtMaxMod"] = "箭伤",
  [":arrowHurtSkill"] = "锁定技，本回合手牌上限-X（X为“箭伤标记”），本回合结束后此标记-1，当此标记为0时失去此技能",
  ["@up_arrowhurt"] = "箭伤+",
  ["#wdtx__archery_attack_skill"] = "所有其他角色需打出一张【闪】，否则受到1点伤害",
  ["wdtx__archery_attack_skill"] = "万箭齐发",
  [":wdtx__archery_attack"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：所有其他角色<br /><b>效果</b>：每名目标角色需打出一张【闪】，否则受到1点伤害。（升级限定问鼎天下模式有效）"..
  "<br /><font color='#90EE90'>等级1：使用此卡不可被响应，受到此牌伤害的目标使其获得【箭伤】技能且获得X+1层“箭伤”标记。（X为等级数）</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1</font>"
}

local wdtx_lightningSkill = fk.CreateActiveSkill{
  name = "wdtx_lightning_skill",
  prompt = "#wdtx_lightning_skill",
  mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
    return user ~= to_select
  end,
  target_filter = function(self, to_select, selected, _, card)
    return #selected == 0 and self:modTargetFilter(to_select, selected, Self.id, card, true)
  end,
  on_use = function(self,room, effect) 
    local tos = TargetGroup:getRealTargets(effect.tos)
    if #tos > 0 then
      local to = room:getPlayerById(tos[1])
      local extra_reduce = effect.card:getMark("@reduce_lightning_num")
      room:setPlayerMark(to,"@lightning_num",5-extra_reduce)
      room:handleAddLoseSkills(to, "lightningTriSkill", nil, false)
    end
  end,
  target_num = 1,
  on_effect = function(self, room, effect)
    local to = room:getPlayerById(effect.to)   
    -- local area = room:getCardArea(effect.card.id)
    -- p(area)
    -- dbg()
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      to = to.id,
      toArea = Card.PlayerJudge,
      moveReason = fk.ReasonJustMove
    }
  end,
  on_nullified = function(self, room, effect)
    local to = room:getPlayerById(effect.to) 
    room:handleAddLoseSkills(to, "-lightningTriSkill", nil, false)
    room:setPlayerMark(to,"@lightning_num",0)
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonPut
    }
  end,
}
local lightningTriSkill = fk.CreateTriggerSkill{
  name = 'lightningTriSkill',
  anim_type = "negative",
  frequency = Skill.Compulsory,
  events = {fk.TurnStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:getMark("@lightning_num") > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:removePlayerMark(player,"@lightning_num",1)
    -- room:notifySkillInvoked(player, self.name, "negative")
    local mark = player:getMark("@lightning_num")
    if mark <= 0 then
      room:damage{
        to = player,
        damage = 3,
        damageType = fk.ThunderDamage,
        skillName = self.name,
      }
      room:handleAddLoseSkills(player, "-lightningTriSkill", nil, false)
      local card = table.find(player.player_cards[Player.Judge],function(cid) return Fk:getCardById(cid).name == "wdtx_lightning" end)
      -- card = Fk:getCardById(card)
      if not card then return end
      room:moveCards{
        from = player.id,
        fromArea = Card.PlayerJudge,
        ids = {card},
        toArea = Card.DiscardPile,
        moveReason = fk.ReasonJustMove
      }
    end
  end,
}
local lightningMoveSkill = fk.CreateTriggerSkill{
  name = "#lightningMoveSkill",
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.BeforeCardsMove},
  can_trigger = function (self, event, target, player, data) 
    if not player:hasSkill(self) then return end
    for _, move in ipairs(data) do
      if move.from and move.from == player.id and move.toArea ~= Card.Processing then
        -- p(data)
        -- dbg()
        for _, info in ipairs(move.moveInfo) do
          local card = Fk:getCardById(info.cardId)
          if card.name == "wdtx_lightning" and info.fromArea == Card.PlayerJudge then self.cost_data = info.cardId return true end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:handleAddLoseSkills(player, "-lightningTriSkill", nil, false)
    room:setPlayerMark(player,"@lightning_num",0)
  end,
}
lightningTriSkill:addRelatedSkill(lightningMoveSkill)
Fk:addSkill(lightningTriSkill)
local wdtx_lightning = fk.CreateDelayedTrickCard{
  name = "wdtx_lightning",
  suit = Card.Spade,
  number = 1,
  skill = wdtx_lightningSkill,
}
extension_card:addCards({
  wdtx_lightning,
})
Fk:loadTranslationTable{
  ["wdtx_lightning"] = "闪电",
  ["#lightningMoveSkill"] = "落雷",
  ["@lightning_num"] = "闪电倒计:",
  ["@reduce_lightning_num"] = "倒计-",
  ["lightningTriSkill"] = "落雷",
  [":lightningTriSkill"] = "锁定技，每个回合开始时，拥有“闪电倒计”标记的角色其标记-1。当此标记为0时其受到3点雷电伤害，然后其失去此技能并将此卡置入弃牌堆。",
  ["#wdtx_lightning_skill"] = "将此牌置于目标角色判定区内，其获得5个“闪电倒计”标记与【落雷】技能。",
  [":wdtx_lightning"] = "延时锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：你<br /><b>效果</b>：将此牌置于目标角色判定区内，其获得5个“闪电倒计”标记与【落雷】技能。"..
  "<br /><font color='#90EE90'>等级1：“闪电倒计”标记-1。</font>"
}

local wdtx__indulgenceSkill = fk.CreateActiveSkill{
  name = "wdtx__indulgence_skill",
  prompt = "#wdtx__indulgence_skill",
  on_use = function(self,room, effect) 
    local tos = TargetGroup:getRealTargets(effect.tos)
    if #tos > 0 then
      local to = room:getPlayerById(tos[1])
      local extra_reduce = effect.card:getMark("@indulgence_num")
      room:setPlayerMark(to,"@indulgence_num",extra_reduce)
    end
  end,
  mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
    return user ~= to_select
  end,
  target_filter = function(self, to_select, selected, _, card)
    return #selected == 0 and self:modTargetFilter(to_select, selected, Self.id, card, true)
  end,
  target_num = 1,
  on_effect = function(self, room, effect)
    local to = room:getPlayerById(effect.to)
    local judge = {
      who = to,
      reason = "indulgence",
      pattern = ".|.|spade,club,diamond",
    }
    room:judge(judge)
    local result = judge.card
    if result.suit ~= Card.Heart then
      to:skip(Player.Play)
    end
    local mark = to:getMark("@indulgence_num")
    if mark == 0 then
      self:onNullified(room, effect)
    else
      room:removePlayerMark(to,"@indulgence_num",1)
      room:moveCards{
        ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
        to = to.id,
        toArea = Card.PlayerJudge,
        moveReason = fk.ReasonJustMove
      }
    end  
  end,
  on_nullified = function(self, room, effect)
    local to = room:getPlayerById(effect.to)
    local mark = to:getMark("@indulgence_num")
    if mark > 0 then
      room:setPlayerMark(to,"@indulgence_num",0)
    end 
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonUse
    }
  end,
}
-- local indulgenceMoveSkill = fk.CreateTriggerSkill{
--   name = "#indulgenceMoveSkill",
--   anim_type = "support",
--   frequency = Skill.Compulsory,
--   events = {fk.BeforeCardsMove},
--   can_trigger = function (self, event, target, player, data) 
--     if not player:hasSkill(self) then return end
--     for _, move in ipairs(data) do
--       if move.from and move.from == player.id and move.toArea ~= Card.Processing then
--         for _, info in ipairs(move.moveInfo) do
--           local card = Fk:getCardById(info.cardId)
--           if card.name == "wdtx__indulgence" and info.fromArea == Card.PlayerJudge then self.cost_data = info.cardId return true end
--         end
--       end
--     end
--   end,
--   on_use = function(self, event, target, player, data)
--     local room = player.room
--     room:handleAddLoseSkills(player, "-#indulgenceMoveSkill", nil, false)
--     room:setPlayerMark(player,"@indulgence_num",0)
--   end,
-- }
-- Fk:addSkill(indulgenceMoveSkill)
local wdtx__indulgence = fk.CreateDelayedTrickCard{
  name = "wdtx__indulgence",
  suit = Card.Spade,
  number = 6,
  skill = wdtx__indulgenceSkill,
}

extension_card:addCards({
  wdtx__indulgence,
})
Fk:loadTranslationTable{
  ["wdtx__indulgence"] = "乐不思蜀",
  ["@indulgence_num"] = "思蜀+",
  ["wdtx__indulgence_skill"] = "乐不思蜀",
  ["#wdtx__indulgence_skill"] = "选择一名其他角色，将此牌置于其判定区内。其判定阶段判定：<br />若结果不为<font color='#CC3131'>♥</font>，其跳过出牌阶段（升级仅限问鼎天下模式）",
  [":wdtx__indulgence"] = "延时锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：一名其他角色<br /><b>效果</b>：将此牌置于目标角色判定区内。其判定阶段进行判定：若结果不为<font color='#CC3131'>♥</font>，其跳过出牌阶段。然后将【乐不思蜀】置入弃牌堆。（升级仅限问鼎天下模式）"..
  "<br /><font color='#90EE90'>等级1：指向目标后使其获得X层“思蜀”标记。当其因此卡判定结束时，若还有该标记，则此卡继续置入其判定区，然后此标记-1。否则将此卡置入弃牌堆。（X为等级数）。</font>"
}

local wdtx__analepticSkill = fk.CreateActiveSkill{
  name = "wdtx__analeptic_skill",
  prompt = "#wdtx__analeptic_skill",
  max_turn_use_time = 1,
  mod_target_filter = function(self, to_select, _, _, card, _)
    return not table.find(Fk:currentRoom().alive_players, function(p)
      return p.dying
    end)
  end,
  can_use = function(self, player, card, extra_data)
    return not player:isProhibited(player, card) and ((extra_data and (extra_data.bypass_times or extra_data.analepticRecover)) or
      self:withinTimesLimit(player, Player.HistoryTurn, card, "analeptic", player))
  end,
  on_use = function(_, _, use)
    if not use.tos or #TargetGroup:getRealTargets(use.tos) == 0 then
      use.tos = { { use.from } }
    end

    if use.extra_data and use.extra_data.analepticRecover then
      use.extraUse = true
    end
  end,
  on_effect = function(_, room, effect)
    local to = room:getPlayerById(effect.to)
    if effect.extra_data and effect.extra_data.analepticRecover then
      room:recover({
        who = to,
        num = 1,
        recoverBy = room:getPlayerById(effect.from),
        card = effect.card,
      })
    else
      if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@up_analep") > 0 and to.id > 0 then 
        local Wdtx = room.logic.Wdtx
        local upcards = Wdtx:getCanUpCards(to:getCardIds("h"))
        if #upcards == 0 then room:doBroadcastNotify("ShowToast","手牌没有可升级") return end
        local seln = effect.card:getMark("@up_analep")
        -- p(table.map(upcards,function(id) return Fk:getCardById(id).name end))
        -- dbg()
        local success, dat = room:askForUseActiveSkill(to,"wdtxFindUpCardsSkill","#wdtxFindUpCardsSkill:::"..seln,true,{target_cards = upcards,card_num = seln})
        if success and #dat.cards > 0 then
          Wdtx:upCardsByTmp(dat.cards)
        end
      end
      to.drank = to.drank + 1 + ((effect.extra_data or {}).additionalDrank or 0)
      room:broadcastProperty(to, "drank")
    end
  end
}
local wdtxFindUpCardsSkill = fk.CreateActiveSkill{
  name = "wdtxFindUpCardsSkill",
  card_filter = function(self, to_select, selected)
    return table.contains(self.target_cards,to_select)
  end,
  target_filter = function() return false end,
}
Fk:addSkill(wdtxFindUpCardsSkill)
local wdtx__analeptic = fk.CreateBasicCard{
  name = "wdtx__analeptic",
  suit = Card.Spade,
  number = 3,
  skill = wdtx__analepticSkill,
}

extension_card:addCards({
  wdtx__analeptic,
})
Fk:loadTranslationTable{
  ["wdtx__analeptic"] = "酒",
  ["@up_analep"] = "升级+",
  ["wdtxFindUpCardsSkill"] = "升级卡牌",
  ["#wdtxFindUpCardsSkill"] = "升级卡牌：选择最多%arg张手牌进行临时升级",
  ["wdtx__analeptic_skill"] = "酒",
  ["#wdtx__analeptic_skill"] = "你于此回合内使用的下一张【杀】的伤害值基数+1。<br/>（升级仅限问鼎天下模式）",
  [":wdtx__analeptic"] = "基本牌<br /><b>时机</b>：出牌阶段/你处于濒死状态时<br /><b>目标</b>：你<br /><b>效果</b>：目标角色本回合使用的下一张【杀】将要造成的伤害+1/目标角色回复1点体力。（升级仅限问鼎天下模式）"..
  "<br /><font color='#90EE90'>等级1：你可以选择1张手牌进行临时升级。（当临时升级的卡牌进入弃卡区则移除其临时升级标记）</font>"
}

local wdtx_recast = fk.CreateActiveSkill{
  name = "wdtx_recast",
  prompt = "#wdtx_recast",
  target_num = 0,
  on_use = function(_, room, effect)
    room:recastCard(effect.cards, room:getPlayerById(effect.from))
    if room.logic.class.name == "wdtx_logic" and #effect.cards > 0 and Fk:getCardById(effect.cards[1]):getMark("@rechain_num") > 0 then
      room.logic.Wdtx:drawCards(1)
    end
  end
}
Fk:addSkill(wdtx_recast)

function ActiveSkill:getMaxTargetNum(player, card)
  local ret
  if self.target_num then ret = self.target_num
  elseif self.target_num_table then ret = self.target_num_table
  else ret = self.max_target_num end

  if type(ret) == "function" then
    ret = ret(self,card)
  end
  if type(ret) == "table" then
    ret = ret[#ret]
  end

  local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable
  for _, skill in ipairs(status_skills) do
    local correct = skill:getExtraTargetNum(player, self, card)
    if correct == nil then correct = 0 end
    ret = ret + correct
  end
  return ret
end

local wdtx__ironChainCardSkill = fk.CreateActiveSkill{
  name = "wdtx__iron_chain_skill",
  prompt = "#wdtx__iron_chain_skill",
  min_target_num = 1,
  max_target_num = function(self,card)
    if card:getMark("@rechain_num") > 0 then
      return 3
    end
    return 2
  end,
  mod_target_filter = Util.TrueFunc,
  target_filter = function(self, to_select, selected, _, card)
    if #selected < self:getMaxTargetNum(Self, card) + card:getMark("@rechain_num") then
      return self:modTargetFilter(to_select, selected, Self.id, card)
    end
  end,
  on_effect = function(_, room, effect)
    local to = room:getPlayerById(effect.to)
    if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@@alone_facedown") > 0 and #TargetGroup:getRealTargets(effect.tos) == 1 then
      to:turnOver()
    end
    to:setChainState(not to.chained)
  end,
}

local wdtx__ironChain = fk.CreateTrickCard{
  name = "wdtx__iron_chain",
  skill = wdtx__ironChainCardSkill,
  special_skills = { "wdtx_recast" },
  multiple_targets = true,
}
extension_card:addCards{
  wdtx__ironChain:clone(Card.Spade, 11),
}
Fk:loadTranslationTable{
  ["wdtx__iron_chain"] = "铁索连环",
  ["wdtx_recast"] = "重铸",
  [":wdtx_recast"] = "你可以将此牌置入弃牌堆，然后摸一张牌。（升级后再摸一张牌）",
  ["#wdtx_recast"] = "将此牌置入弃牌堆，然后摸一张牌（升级后再摸一张牌）",
  ["@rechain_num"] = "连铸+",
  ["@@alone_facedown"] = "连翻",
  ["wdtx__iron_chain_skill"] = "铁索连环",
  ["#wdtx__iron_chain_skill"] = "选择一至两名角色，这些角色横置或重置",
  [":wdtx__iron_chain"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：一至两名角色<br /><b>效果</b>：横置或重置目标角色的武将牌。（升级仅限问鼎天下模式）"..
  "<br /><font color='#90EE90'>等级1：连环选择目标+1，重铸多摸1张牌。</font>"..
  "<br /><font color='#90EE90'>等级2：连环目标为1时且其被横置。则使其翻面。</font>",
}

local wdtx__fireAttackSkill = fk.CreateActiveSkill{
  name = "wdtx__fire_attack_skill",
  prompt = "#wdtx__fire_attack_skill",
  target_num = 1,
  mod_target_filter = function(_, to_select, _, _, _, _)
    local to = Fk:currentRoom():getPlayerById(to_select)
    return not to:isKongcheng()
  end,
  target_filter = function(self, to_select, selected, _, card)
    if #selected < self:getMaxTargetNum(Self, card) then
      return self:modTargetFilter(to_select, selected, Self.id, card)
    end
  end,
  on_effect = function(self, room, cardEffectEvent)
    local from = room:getPlayerById(cardEffectEvent.from)
    local to = room:getPlayerById(cardEffectEvent.to)
    local mark = cardEffectEvent.card:getMark("@up_fire")
    if mark == 0 then
      if to:isKongcheng() then return end
      local showCard = room:askForCard(to, 1, 1, false, self.name, false, ".|.|.|hand", "#fire_attack-show:" .. from.id)[1]
      to:showCards(showCard)
      showCard = Fk:getCardById(showCard)
      local cards = room:askForDiscard(from, 1, 1, false, self.name, true,".|.|" .. showCard:getSuitString(), "#fire_attack-discard:" .. to.id .. "::" .. showCard:getSuitString())
      if #cards > 0 then
        room:damage({
          from = from,
          to = to,
          card = cardEffectEvent.card,
          damage = 1,
          damageType = fk.FireDamage,
          skillName = self.name
        })
      end
    elseif mark > 0 then
      local firefunc = function() 
        room:damage({
          from = from,
          to = to,
          card = cardEffectEvent.card,
          damage = 1,
          damageType = fk.FireDamage,
          skillName = self.name
        })
        room:addPlayerMark(to,"@up_fire",mark+1)
        if not to:hasSkill("burningSkill") then
          room:handleAddLoseSkills(to, "burningSkill", nil, false)
        end 
      end
      if mark < 3 then
        firefunc()
      elseif mark > 2 then
        firefunc()
        local firetars = {}
        local nextalive = to:getNextAlive()
        if nextalive and nextalive.role == to.role then
          table.insert(firetars,nextalive)
        end
        local lastar = table.find(room.alive_players, function (p)
          return p:getNextAlive() == to
        end)
        if lastar and lastar.role == to.role then
          table.insert(firetars,lastar)
        end
        for _, tar in ipairs(firetars) do
          room:damage({
            from = from,
            to = tar,
            -- card = cardEffectEvent.card,
            damage = 1,
            damageType = fk.FireDamage,
            skillName = self.name
          })
          room:addPlayerMark(tar,"@up_fire",2)
          if not tar:hasSkill("burningSkill") then
            room:handleAddLoseSkills(tar, "burningSkill", nil, false)
          end          
        end
      end
    end
  end,
}
local burningSkill = fk.CreateTriggerSkill{
  name = 'burningSkill',
  anim_type = "negative",
  priority = 0.09,
  frequency = Skill.Compulsory,
  events = {fk.DamageInflicted,fk.TurnStart,fk.EventLoseSkill},
  can_trigger = function(self, event, target, player, data)
    if event == fk.DamageInflicted then
      return player:hasSkill(self) and target == player and data.damageType == fk.FireDamage
    elseif event == fk.TurnStart then
      return target == player and player:getMark("@up_fire") > 0
    else
      return player == target and data == self and player:getMark("@up_fire") > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DamageInflicted then
      room:addPlayerMark(player,"@up_fire",1)
    elseif event == fk.TurnStart then
      local curmark = player:getMark("@up_fire")
      local firedamge = math.floor(curmark/2)
      if firedamge > 0 then
        room:loseHp(player,firedamge,self.name)
      end
      room:removePlayerMark(player,"@up_fire",1)
      if curmark == 1 then
        room:handleAddLoseSkills(player, "-burningSkill", nil, false)
      end
    else
      room:setPlayerMark(player,"@up_fire",0)
    end  
  end,
}
Fk:addSkill(burningSkill)
local wdtx__fire_attack = fk.CreateTrickCard{
  name = "wdtx__fire_attack",
  skill = wdtx__fireAttackSkill,
  is_damage_card = true,
}
extension_card:addCards{
  wdtx__fire_attack:clone(Card.Heart, 2),
}
Fk:loadTranslationTable{
  ["wdtx__fire_attack"] = "火攻",
  ["burningSkill"] = "灼伤",
  [":burningSkill"] = "锁定技，你的回合开始时你流失X/2(向下取整)体力，然后“灼烧”标记-1，当此标记为0时失去此技能。(X为“灼烧”标记)",
  ["@up_fire"] = "灼烧+",
  ["wdtx__fire_attack_skill"] = "火攻",
  [":wdtx__fire_attack"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：一名有手牌的角色<br /><b>效果</b>：目标角色展示一张手牌，"..
  "然后你可以弃置一张与此牌花色相同的手牌对其造成1点火焰伤害。（升级仅限问鼎天下模式）"..
  "<br /><font color='#90EE90'>等级1：无需弃牌，火攻后目标获得【灼伤】技能且获得X+1层“灼烧”标记（X为等级数）。</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1。</font>"..
  "<br /><font color='#90EE90'>等级3：继承等级1，目标邻近至多2名友方也受到此卡1点火属性伤害且其友方均获得2层“灼烧”标记</font>",
  -- ["#fire_attack-show"] = "%src 对你使用了火攻，请展示一张手牌",
  -- ["#fire_attack-discard"] = "你可弃置一张 %arg 手牌，对 %src 造成1点火属性伤害",
  ["#wdtx__fire_attack_skill"] = "选择一名有手牌的角色，令其展示一张手牌，<br />然后你可以弃置一张与此牌花色相同的手牌对其造成1点火焰伤害（升级仅限问鼎天下模式）",
}

local wdtx__supplyShortageSkill = fk.CreateActiveSkill{
  name = "wdtx__supply_shortage_skill",
  prompt = "#wdtx__supply_shortage_skill",
  distance_limit = 1,
  mod_target_filter = function(self, to_select, _, user, card, distance_limited)
    local player = Fk:currentRoom():getPlayerById(to_select)
    local from = Fk:currentRoom():getPlayerById(user)
    return from ~= player and not (distance_limited and not self:withinDistanceLimit(from, false, card, player))
  end,
  target_filter = function(self, to_select, selected, _, card, extra_data)
    local count_distances = not (extra_data and extra_data.bypass_distances)
    return #selected == 0 and self:modTargetFilter(to_select, selected, Self.id, card, count_distances)
  end,
  target_num = 1,
  on_effect = function(self, room, effect)
    local to = room:getPlayerById(effect.to)
    local judge = {
      who = to,
      reason = "wdtx__supply_shortage_skill",
      pattern = ".|.|spade,heart,diamond",
    }
    room:judge(judge)
    local result = judge.card
    if result.suit ~= Card.Club then
      to:skip(Player.Draw)
      if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@weak_hurt") > 0 then
        room:addPlayerMark(to,"@weak_hurt",effect.card:getMark("@weak_hurt") + 1)
        room:handleAddLoseSkills(to, "weak_hurt_skill", nil, false)
      end     
    end
    self:onNullified(room, effect)
  end,
  on_nullified = function(self, room, effect)
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonUse
    }
  end,
}
local weakHurtSkill = fk.CreateTriggerSkill{
  name = "weak_hurt_skill",
  anim_type = "negative",
  priority = 0.08,
  frequency = Skill.Compulsory,
  events = {fk.DamageInflicted,fk.TurnEnd,fk.EventLoseSkill},
  can_trigger = function(self, event, target, player, data)
    if event == fk.DamageInflicted then
      return player:hasSkill(self) and data.from == player and data.card and not player.dead and player:getMark("@weak_hurt") > 0
    elseif event == fk.TurnEnd then
      return player:hasSkill(self) and target == player and player:getMark("@weak_hurt") > 0
    else
      return player == target and data == self and (player:getMark("weakhurt_damaged") > 0 or player:getMark("@weak_hurt") > 0)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DamageInflicted then
      local weakhurt_damaged = player:getMark("weakhurt_damaged")
      local per = 2
      local per_damage = data.damage / per
      local mod_damage = data.damage % per
      per_damage = per_damage > 0 and math.floor(per_damage) or 0
      mod_damage = (mod_damage + weakhurt_damaged) % per == 0 and 1 or 0
      room:setPlayerMark(player,"weakhurt_damaged",weakhurt_damaged+data.damage)
      if per_damage + mod_damage > 0 then
        data.damage = data.damage - (per_damage + mod_damage)
      end
    elseif event == fk.TurnEnd then
      local mark = player:getMark("@weak_hurt")
      room:removePlayerMark(player,"@weak_hurt",1)
      if mark == 1 then
        room:handleAddLoseSkills(player, "-weak_hurt_skill", nil, false)
      end
    else
      room:setPlayerMark(player,"weakhurt_damaged",0)
      room:setPlayerMark(player,"@weak_hurt",0)
    end  
  end,
}
Fk:addSkill(weakHurtSkill)
local wdtx__supply_shortage = fk.CreateDelayedTrickCard{
  name = "wdtx__supply_shortage",
  skill = wdtx__supplyShortageSkill,
}
extension_card:addCards{
  wdtx__supply_shortage:clone(Card.Spade, 10),
}
Fk:loadTranslationTable{
  ["wdtx__supply_shortage"] = "兵粮寸断",
  ["weak_hurt_skill"] = "虚弱",
  [":weak_hurt_skill"] = "锁定技，每当造成共2点伤害时伤害-1，你回合结束后“虚弱”标记-1，当此标记为0时失去此技能。",
  ["@weak_hurt"] = "虚弱+",
  [":wdtx__supply_shortage"] = "延时锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：距离1的一名其他角色"..
  "<br /><b>效果</b>：将此牌置于目标角色判定区内。其判定阶段进行判定：若结果不为♣，其跳过摸牌阶段。然后将【兵粮寸断】置入弃牌堆。（升级仅限问鼎天下模式）"..
  "<br /><font color='#90EE90'>等级1：此牌判定成功后目标角色获得【虚弱】技能并获得X+1层“虚弱”标记（X为等级数）。</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1。</font>",
  ["#wdtx__supply_shortage_skill"] = "选择距离1的一名角色，将此牌置于其判定区内。其判定阶段判定：<br />若结果不为♣，其跳过摸牌阶段（升级仅限问鼎天下模式）",
  ["wdtx__supply_shortage_skill"] = "兵粮寸断",
}

local jc_skills = {
  "gongjian","ex__biyue","zuilun","qiangwu","ol_ex__qiangxi","ol_ex__luanji","ty_ex__sanyao","m_ex__xianzhen","ol_ex__jieming",
  "tianyi","mansi","huayi","souying","pingxi","ty_ex__wurong","xuezhao","ty_ex__qingxi","daoshu","ex__longdan","m_ex__mieji",
  "ex__guose","guolun","duliang","os__gongxin","kunfen","ol_ex__jushou","os_ex__bingyi","miji","zhengu","juece","sp__youdi", "kuanshi", "suizheng", "m_ex__jieyue",
  "zhuihuan","os__juchen","ty_ex__jingce","linghui","lueming", "jijie","ty__lianzhu","ex__fanjian","weimeng","poxi","ty__kuangfu","ty_ex__gongqi",
  "ol_ex__tiaoxin","quhu","nuchen","weiwu","m_ex__yanzhu","ty__jianji","changqu","jiuxianc",
}
local wdtx__jiancaiCardSkill = fk.CreateActiveSkill{
  name = "wdtx__jiancai_skill",
  prompt = "#wdtx__jiancai_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
      cardUseEvent.tos = { { cardUseEvent.from } }
    end
  end,
  on_effect = function(self, room, effect)
    local target = room:getPlayerById(effect.to)
    if target.dead then return end
    local jiancailv = effect.card:getMark("@jiancailv")
    
    local newskills = {}
    for _, ski in ipairs(jc_skills) do
      if not target:hasSkill(ski) then
        table.insert(newskills,ski)
      end
    end
    local randchc = table.random(newskills,3+(jiancailv * 2))
    local chs = room:askForChoices(target,randchc,1+jiancailv,1+jiancailv,"#wdtx_rule","#wdtx_rule",false,true)
    for _,skill in ipairs(chs) do
      local getskillstr = target:getMark("losejc")
      if getskillstr == 0 then
        local getskill = skill.."|".."#losejcSkill"
        room:setPlayerMark(target,"losejc",skill)
        room:handleAddLoseSkills(target,getskill,nil,false)
      else
        getskillstr = getskillstr.."|"..skill
        room:setPlayerMark(target,"losejc",getskillstr)
        room:handleAddLoseSkills(target,skill,nil,false)
      end
    end
  end
}
local losejcSkill = fk.CreateTriggerSkill{
  name = '#losejcSkill',
  anim_type = "negative",
  priority = 0.011,
  frequency = Skill.Compulsory,
  refresh_events = {fk.TurnEnd},
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and player:getMark("losejc") ~= 0
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local skills = player:getMark("losejc")
    local skillstb = skills:split("|")
    -- local loseskills = "-"..skill.."|-"..self.name
    local loseskills = ""
    for _,ski in ipairs(skillstb) do
      loseskills = loseskills.."-"..ski.."|"
    end
    loseskills = loseskills..self.name
    room:handleAddLoseSkills(player, loseskills, nil, false)
    room:setPlayerMark(player,"losejc",0)
  end,
}
Fk:addSkill(losejcSkill)

local wdtx__jiancai = fk.CreateTrickCard{
  name = "wdtx__jiancai",
  suit = Card.Heart,
  number = 6,
  skill = wdtx__jiancaiCardSkill,
}
extension_card:addCards{
  wdtx__jiancai,
}
Fk:loadTranslationTable{
  ["wdtx__jiancai"] = "荐才",
  ["@jiancailv"] = "品质+",
  ["wdtx__jiancai_skill"] = "荐才",
  ["#losejcSkill"] = "",
  ["#wdtx__jiancai_skill"] = "你可以从技能池里3选1获得一个技能，回合结束时失去该技能。",
  [":wdtx__jiancai"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：你可以从技能池里3选1获得一个技能，回合结束时失去该技能。（升级仅限问鼎天下模式）"..
  "<br /><font color='#90EE90'>等级1：3选1改为5选2.</font>",
}

local wdtx__zhenqiaoCardSkill = fk.CreateActiveSkill{
  name = "wdtx__zhenqiao_skill",
  prompt = "#wdtx__zhenqiao_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
      cardUseEvent.tos = { { cardUseEvent.from } }
    end
  end,
  on_effect = function(self, room, effect)
    local target = room:getPlayerById(effect.to)
    if target.dead then return end
    local zhenqiaolv = effect.card:getMark("@zhenqiaolv")
    if not target:hasSkill("zhenqiao") then
      if zhenqiaolv > 0 then 
        room:setPlayerMark(target,"@zhenqiaolv",zhenqiaolv)
      end
      room:handleAddLoseSkills(target,"zhenqiao|#losezqSkill",nil,false)
    end
  end
}
local losezqSkill = fk.CreateTriggerSkill{
  name = '#losezqSkill',
  anim_type = "negative",
  priority = 0.012,
  frequency = Skill.Compulsory,
  refresh_events = {fk.TurnEnd},
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and player:hasSkill("zhenqiao")
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local zhenqiaolv = player:getMark("@zhenqiaolv")
    if zhenqiaolv <= 0 then
      room:handleAddLoseSkills(player, "-zhenqiao|-"..self.name, nil, false)
    else
      room:removePlayerMark(player,"@zhenqiaolv",1)
    end
  end,
}
Fk:addSkill(losezqSkill)

local wdtx__zhenqiao = fk.CreateTrickCard{
  name = "wdtx__zhenqiao",
  suit = Card.Club,
  number = 6,
  skill = wdtx__zhenqiaoCardSkill,
}
extension_card:addCards{
  wdtx__zhenqiao,
}
Fk:loadTranslationTable{
  ["wdtx__zhenqiao"] = "振鞘",
  ["@zhenqiaolv"] = "振鞘延长+",
  ["wdtx__zhenqiao_skill"] = "振鞘",
  ["#losezqSkill"] = "",
  ["#wdtx__zhenqiao_skill"] = "你获得【振鞘】技能，回合结束失去此技能。",
  [":wdtx__zhenqiao"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：你获得【振鞘】技能，回合结束失去此技能。（升级仅限问鼎天下模式）"..
  "<br /><font color='#90EE90'>等级1：回合结束失去【振鞘】技能改为延长X回合后失去此技能。（X为等级数）</font>"..
  "<br /><font color='#90EE90'>等级2：继承等级1</font>",
}

local wdtx__boshiCardSkill = fk.CreateActiveSkill{
  name = "wdtx__boshi_skill",
  prompt = "#wdtx__boshi_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
      cardUseEvent.tos = { { cardUseEvent.from } }
    end
  end,
  on_effect = function(self, room, effect)
    local target = room:getPlayerById(effect.to)
    if target.dead then return end
    if room.logic.class.name == "wdtx_logic" and target.id > 0 then
      local Wdtx = room.logic.Wdtx
      local upcards = Wdtx:getCanUpCards(target:getCardIds("h"))
      if #upcards == 0 then room:doBroadcastNotify("ShowToast","手牌没有可升级") return end
      Wdtx:upCardsByTmp(upcards)
    end
  end
}

local wdtx__boshi = fk.CreateTrickCard{
  name = "wdtx__boshi",
  suit = Card.Spade,
  number = 6,
  skill = wdtx__boshiCardSkill,
}
extension_card:addCards{
  wdtx__boshi,
}
Fk:loadTranslationTable{
  ["wdtx__boshi"] = "博识",
  ["@@costcard"] = "消耗",
  ["@@staymax"] = "停留",
  ["wdtx__boshi_skill"] = "博识",
  ["#losezqSkill"] = "",
  ["#wdtx__boshi_skill"] = "临时升级你所有手牌。（当临时升级的卡牌进入弃卡区则移除其临时升级标记。此卡限问鼎天下模式）",
  [":wdtx__boshi"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：临时升级你所有手牌。（当临时升级的卡牌进入弃卡区则移除其临时升级标记。此卡限问鼎天下模式）"..
  "<br /><font color='#90EE90'>等级1：获得”停留“标记（问鼎天下的玩家当有此标记的卡牌在手中会跳过弃牌阶段）。</font>"
}

local wdtx__crossbowSkill = fk.CreateTargetModSkill{
  name = "#wdtx__crossbow_skill",
  attached_equip = "wdtx__crossbow",
  residue_func = function(self, player, skill, scope,card)
    if player:hasSkill(self) and skill.trueName == "slash_skill" and scope == Player.HistoryPhase then
      return 1 + player:getMark("slash_num")
    end
  end,
}
-- wdtx__crossbowSkill:addRelatedSkill("#crossbowAudio")
Fk:addSkill(wdtx__crossbowSkill)

local wdtx__crossbow = fk.CreateWeapon{
  name = "wdtx__crossbow",
  suit = Card.Club,
  number = 1,
  attack_range = 1,
  equip_skill = wdtx__crossbowSkill,
  on_install = function(self, room, player)
    room:handleAddLoseSkills(player, self.equip_skill.name, nil, false)
    if self:getMark("@slash_num") > 0 then
      room:setPlayerMark(player,"slash_num",self:getMark("@slash_num"))
    end
  end,
  on_uninstall = function(self, room, player)
    room:handleAddLoseSkills(player,"-"..self.equip_skill.name, nil, false)
    if self:getMark("@slash_num") > 0 or player:getMark("slash_num") > 0 then
      room:setPlayerMark(player,"slash_num",0)
    end
  end,
}

extension_card:addCards({
  wdtx__crossbow,
})
Fk:loadTranslationTable{
  ["wdtx__crossbow"] = "破损的连弩",
  ["@slash_num"] = "杀数+",
  ["#wdtx__crossbow_skill"] = "诸葛连弩",
  [":wdtx__crossbow"] = "装备牌·武器<br /><b>攻击范围</b>：１<br /><b>武器技能</b>：锁定技，你于出牌阶段内使用【杀】次数+1。"..
  "<br /><font color='#90EE90'>等级1：升级后额外使用【杀】次数+2</font>"..
  "<br /><font color='#90EE90'>等级2：升级后额外使用【杀】次数+3。</font>"..
  "<br /><font color='#90EE90'>等级3：升级后额外使用【杀】次数+4。</font>",
}

local wdtx__axeSkill = fk.CreateTriggerSkill{
  name = "#wdtx__axe_skill",
  attached_equip = "wdtx__axe",
  priority = 11,
  events = {fk.CardEffectCancelledOut,fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return end
    if event == fk.CardEffectCancelledOut then
      return data.from == player.id and data.card.trueName == "slash" and not player.room:getPlayerById(data.to).dead
    else
      if data.from == player and target ~= player and data.card.trueName == "slash" and not target.dead then
        local eid = player:getEquipment(Card.SubtypeWeapon)
        local card = Fk:getCardById(eid)
        return card:getMark("@up_easyhurt") > 0
      end 
    end    
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.CardEffectCancelledOut then
      local pattern
      if player:getEquipment(Card.SubtypeWeapon) then
        pattern = ".|.|.|.|.|.|^"..tostring(player:getEquipment(Card.SubtypeWeapon))
      else
        pattern = "."
      end
      local cards = room:askForDiscard(player, 2, 2, true, self.name, true, pattern, "#axe-invoke::"..data.to, true)
      if #cards > 0 then
        self.cost_data = cards
        return true
      end
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.CardEffectCancelledOut then
      room:throwCard(self.cost_data, "wdtx__axe", player, player)
      if room.logic.class.name == "wdtx_logic" then
        local eid = player:getEquipment(Card.SubtypeWeapon)
        local card = Fk:getCardById(eid)
        if card:getMark("@up_easyhurt") > 0 then
          local tar = room:getPlayerById(data.to)
          room:addPlayerMark(tar,"@up_easyhurt",card:getMark("@up_easyhurt"))
          if not tar:hasSkill("easyHurtSkill") then
            room:handleAddLoseSkills(tar, "easyHurtSkill", nil, false)
          end
        end
      end
      return true
    else
      local tar = target
      room:addPlayerMark(tar,"@up_easyhurt",1)
      if not tar:hasSkill("easyHurtSkill") then
        room:handleAddLoseSkills(tar, "easyHurtSkill", nil, false)
      end
    end
  end,
}
Fk:addSkill(wdtx__axeSkill)
local wdtx__axe = fk.CreateWeapon{
  name = "wdtx__axe",
  suit = Card.Diamond,
  number = 5,
  attack_range = 3,
  equip_skill = wdtx__axeSkill,
}

extension_card:addCards({
  wdtx__axe,
})
Fk:loadTranslationTable{
  ["wdtx__axe"] = "贯石斧",
  -- ["@up_easyhurt"] = "杀数+",
  ["#wdtx__axe_skill"] = "贯石斧",
  [":wdtx__axe"] = "装备牌·武器<br /><b>攻击范围</b>：３<br /><b>武器技能</b>：当你使用的【杀】被【闪】抵消后，你可以弃置两张牌，则此【杀】继续造成伤害。"..
  "<br /><font color='#90EE90'>等级1：使用【杀】造成伤害后使其获得【易伤】技能且其额外获得X层“易伤”标记。如果发动此牌效果再额外获得1层“易伤”标记。（X为等级数）</font>"
}

local wdtx__gudingSkill = fk.CreateTriggerSkill{
  name = "#wdtx__guding_blade_skill",
  attached_equip = "wdtx__guding_blade",
  frequency = Skill.Compulsory,
  events = {fk.DamageCaused},
  can_trigger = function(self, _, target, player, data)
    local logic = player.room.logic
    if target == player and player:hasSkill(self) and
    data.to:isKongcheng() and data.card and data.card.trueName == "slash" then
      return data.by_user
    end
  end,
  on_use = function(_, _, _, _, data)
    data.damage = data.damage + 1
  end,
}
Fk:addSkill(wdtx__gudingSkill)
local gudingBlade = fk.CreateWeapon{
  name = "wdtx__guding_blade",
  suit = Card.Spade,
  number = 1,
  attack_range = 2,
  equip_skill = wdtx__gudingSkill,
  on_install = function(self, room, player)
    room:handleAddLoseSkills(player, self.equip_skill.name, nil, false)
    if self:getMark("@@up_pojun") > 0 then
      room:handleAddLoseSkills(player, "m_ex__pojun", nil, false)
    end
  end,
  on_uninstall = function(self, room, player)
    room:handleAddLoseSkills(player,"-"..self.equip_skill.name, nil, false)
    if self:getMark("@@up_pojun") > 0 then
      room:handleAddLoseSkills(player, "-m_ex__pojun", nil, false)
    end
  end,
}

extension_card:addCard(gudingBlade)
Fk:loadTranslationTable{
  ["wdtx__guding_blade"] = "古锭刀",
  ["@@up_pojun"] = "界破军",
  [":wdtx__guding_blade"] = "装备牌·武器<br /><b>攻击范围</b>：２<br /><b>武器技能</b>：锁定技。每当你使用【杀】对目标角色造成伤害时，若该角色没有手牌，此伤害+1。"..
  "<br /><font color='#90EE90'>等级1：装备后你获得手杀【界破军】技能</font>",
  ["#wdtx__guding_blade_skill"] = "古锭刀",
}

local wdtx__fanSkill = fk.CreateTriggerSkill{
  name = "#wdtx__fan_skill",
  attached_equip = "wdtx__fan",
  priority = 13,
  events = { fk.AfterCardUseDeclared },
  can_trigger = function(self, _, target, player, data)
    return target == player and player:hasSkill(self) and (data.card.name == "slash" or data.card.name == "wdtx__slash")
  end,
  on_use = function(self, _, target, player, data)
    local room = player.room
    local card = Fk:cloneCard("fire__slash", data.card.suit, data.card.number)
    for k, v in pairs(data.card) do
      if card[k] == nil then
        card[k] = v
      end
    end
    local equipid = player:getEquipment(Card.SubtypeWeapon)
    local ecard = Fk:getCardById(equipid)
    if ecard and ecard:getMark("@up_fire") > 0 then
      local tars = TargetGroup:getRealTargets(data.tos)
      for _,pid in ipairs(tars) do
        local tar = room:getPlayerById(pid)
        room:addPlayerMark(tar,"@up_fire",2)
        if not tar:hasSkill("burningSkill") then
          room:handleAddLoseSkills(tar,"burningSkill",nil,false)
        end
      end
    end
    if data.card:isVirtual() then
      card.subcards = data.card.subcards
    else
      card.id = data.card.id
    end
    card.skillNames = data.card.skillNames
    card.skillName = "wdtx__fan"
    data.card = card
  end,
}
Fk:addSkill(wdtx__fanSkill)
local wdtx__fan = fk.CreateWeapon{
  name = "wdtx__fan",
  suit = Card.Diamond,
  number = 1,
  attack_range = 4,
  equip_skill = wdtx__fanSkill,
}
extension_card:addCard(wdtx__fan)
Fk:loadTranslationTable{
  ["wdtx__fan"] = "朱雀羽扇",
  [":wdtx__fan"] = "装备牌·武器<br /><b>攻击范围</b>：４<br /><b>武器技能</b>：当你声明使用普【杀】后，你可以将此【杀】改为火【杀】。"..
  "<br /><font color='#90EE90'>等级1：使用普【杀】指向目标使其获得【灼伤】技能且其获得两层”灼烧“标记。</font>",
  ["#wdtx__fan_skill"] = "朱雀羽扇",
}

local wdtx__qingGangSkill = fk.CreateTriggerSkill{
  name = "#wdtx__qinggang_sword_skill",
  attached_equip = "wdtx__qinggang_sword",
  priority = 12,
  frequency = Skill.Compulsory,
  events = { fk.TargetSpecified },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and
      data.card and data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(data.to)
    local use_event = room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)
    if use_event == nil then return end
    local equipid = player:getEquipment(Card.SubtypeWeapon)
    local ecard = Fk:getCardById(equipid)
    if ecard and ecard:getMark("@@up_fengren") ~= 0 and not to.dead then
      if #to.player_cards[Player.Equip] > 0 then
        local eid = room:askForCardChosen(player, to, "e", self.name)
        if eid then
          room:throwCard(eid, self.name, to, player)
        end
      end
      data.disresponsiveList = data.disresponsiveList or {}
      table.insertIfNeed(data.disresponsiveList,data.to)
      -- data.additionalDamage = (data.additionalDamage or 0) + 1
    end
    room:addPlayerMark(to, fk.MarkArmorNullified)
    use_event:addCleaner(function()
      room:removePlayerMark(to, fk.MarkArmorNullified)
    end)
  end,
}
Fk:addSkill(wdtx__qingGangSkill)

local qingGang = fk.CreateWeapon{
  name = "wdtx__qinggang_sword",
  suit = Card.Spade,
  number = 6,
  attack_range = 2,
  equip_skill = wdtx__qingGangSkill,
}
extension_card:addCards({
  qingGang,
})
Fk:loadTranslationTable{
  ["wdtx__qinggang_sword"] = "青釭剑",
  ["@@up_fengren"] = "锋刃",
  [":wdtx__qinggang_sword"] = "装备牌·武器<br /><b>攻击范围</b>：２<br /><b>武器技能</b>：锁定技，你的【杀】无视目标角色的防具。"..
  "<br /><font color='#90EE90'>等级1：弃置目标一张装备。【杀】指向目标不可被其响应。</font>",
  ["#wdtx__qinggang_sword_skill"] = "青釭剑",
}
-- --猛杀
-- local strongSlashSkill = fk.CreateActiveSkill{
--   name = "strong__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = clone_slash.skill.canUse,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local strongHurtSkill = fk.CreateTriggerSkill{
--   name = "strong_hurt_skill",
--   anim_type = "control",
--   frequency = Skill.Compulsory,
--   events = {fk.DamageFinished,fk.TurnEnd},
--   can_trigger = function (self, event, target, player, data)
--     if not player:hasSkill(self.name) then return end
--     if event == fk.DamageFinished then
--       return data.card and data.to and data.to == player and data.to:getMark("@strong_hurt") > 0
--     else
--       return player == target
--     end
--   end,
--   on_use = function(self, event, target, player, data)
--     local room = player.room
--     if event == fk.DamageFinished then
--       local tatal_damaged = player:getMark("tatal_damaged")
--       local per_damage = data.damage / 2
--       local mod_damage = data.damage % 2
--       per_damage = per_damage > 0 and math.floor(per_damage) or 0
--       mod_damage = (mod_damage + tatal_damaged) % 2 == 0 and 1 or 0
--       room:setPlayerMark(player,"tatal_damaged",tatal_damaged+data.damage)
--       if per_damage + mod_damage > 0 then
--         room:damage({
--           to = player,
--           damage = per_damage + mod_damage,
--           damageType = fk.NormalDamage,
--           skillName = self.name
--         })
--       end
--     else
--       local mark = player:getMark("@strong_hurt")
--        room:setPlayerMark(player,"@strong_hurt",mark-1)
--       if mark - 1 <= 0 then
--         room:handleAddLoseSkills(player, "-strong_hurt_skill", nil, false)
--       end
--     end
--   end,
-- }
-- Fk:addSkill(strongHurtSkill)
-- local strongSlash = fk.CreateBasicCard{
--   name = "strong__slash",
--   skill = strongSlashSkill,
--   suit = Card.Spade,
--   number = 8,
--   is_damage_card = true,
-- }
-- preLoadCard(strongSlash)
-- extension_card:addCards{
--   strongSlash,
--   strongSlash:clone(Card.Spade, 10),
--   strongSlash:clone(Card.Club, 8),
--   strongSlash:clone(Card.Club, 10),
-- }
-- Fk:loadTranslationTable{
--   ["strong__slash"] = "猛杀",
--   ["strong__slash_skill"] = "对目标角色造成1点伤害并且目标获得2层【重伤】。【重伤】：每当受到两点伤害会额外受到1点伤害，回合结束层数-1",
-- 	[":strong__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成1点伤害并且目标获得2层【重伤】。【重伤】：每当受到两点伤害会额外受到1点伤害，回合结束层数-1",
--   ["#strong__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点重伤伤害",
--   ["#strong__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点重伤伤害",
--   ["strong_hurt_skill"] = "重伤",
--   ["@strong_hurt"] = "重伤",
--   [":strong_hurt_skill"] = "每当受到两点伤害会额外受到1点伤害，回合结束层数-1",
-- }
-- --残杀
-- local weakSlashSkill = fk.CreateActiveSkill{
--   name = "weak__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = clone_slash.skill.canUse,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local weakHurtSkill = fk.CreateTriggerSkill{
--   name = "weak_hurt_skill",
--   anim_type = "control",
--   frequency = Skill.Compulsory,
--   events = {fk.DamageInflicted,fk.TurnEnd},
--   can_trigger = function (self, event, target, player, data)
--     if not player:hasSkill(self.name) then return end
--     if event == fk.DamageInflicted then
--       return data.card and data.from and data.from == player and data.from:getMark("@weak_hurt") > 0
--     else
--       return player == target
--     end
--   end,
--   on_use = function(self, event, target, player, data)
--     local room = player.room
--     if event == fk.DamageInflicted then
--       local tatal_damage = player:getMark("tatal_damage")
--       local per_damage = data.damage / 2
--       local mod_damage = data.damage % 2
--       per_damage = per_damage > 0 and math.floor(per_damage) or 0
--       mod_damage = (mod_damage + tatal_damage) % 2 == 0 and 1 or 0
--       room:setPlayerMark(player,"tatal_damage",tatal_damage + data.damage)
--       if per_damage + mod_damage > 0 then
--         data.damage = data.damage - (per_damage + mod_damage) 
--       end
--     else
--       local mark = player:getMark("@weak_hurt")
--        room:setPlayerMark(player,"@weak_hurt",mark-1)
--       if mark - 1 <= 0 then
--         room:handleAddLoseSkills(player, "-weak_hurt_skill", nil, false)
--       end
--     end
--   end,
-- }
-- Fk:addSkill(weakHurtSkill)
-- local weakSlash = fk.CreateBasicCard{
--   name = "weak__slash",
--   skill = weakSlashSkill,
--   suit = Card.Spade,
--   number = 4,
--   is_damage_card = true,
-- }
-- preLoadCard(weakSlash)
-- extension_card:addCards{
--   weakSlash,
--   weakSlash:clone(Card.Spade, 6),
--   weakSlash:clone(Card.Club, 4),
--   weakSlash:clone(Card.Club, 6),
-- }
-- Fk:loadTranslationTable{
--   ["weak__slash"] = "残杀",
--   ["weak__slash_skill"] = "对目标角色造成1点伤害并且目标获得2层【虚弱】。【虚弱】：每当造成两点伤害前会减少1的伤害，回合结束层数-1",
-- 	[":weak__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成1点伤害并且目标获得2层【虚弱】。【虚弱】：每当造成两点伤害前会减少1的伤害，回合结束层数-1",
--   ["#weak__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点残杀伤害",
--   ["#weak__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点残杀伤害",
--   ["weak_hurt_skill"] = "虚弱",
--   ["@weak_hurt"] = "虚弱",
--   [":weak_hurt_skill"] = "每当造成两点伤害前会减少1的伤害，回合结束层数-1",
-- }
-- --盾杀
-- local shieldSlashSkill = fk.CreateActiveSkill{
--   name = "shield__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = clone_slash.skill.canUse,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local shieldSlash = fk.CreateBasicCard{
--   name = "shield__slash",
--   skill = shieldSlashSkill,
--   suit = Card.Heart,
--   number = 1,
--   is_damage_card = true,
-- }
-- preLoadCard(shieldSlash)
-- extension_card:addCards{
--   shieldSlash,
--   shieldSlash:clone(Card.Heart, 2),
--   shieldSlash:clone(Card.Diamond, 3),
--   shieldSlash:clone(Card.Diamond, 4),
-- }
-- Fk:loadTranslationTable{
--   ["shield__slash"] = "盾杀",
--   ["shield__slash_skill"] = "对目标角色造成1点伤害并且目标获得1层【护甲】",
-- 	[":shield__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成1点伤害并且目标获得1层【护甲】",
--   ["#shield__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点杀伤害",
--   ["#shield__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点杀伤害",
-- }
-- --杀意
-- local likeSlashSkill = fk.CreateActiveSkill{
--   name = "like__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = clone_slash.skill.canUse,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local likeSlash = fk.CreateBasicCard{
--   name = "like__slash",
--   skill = likeSlashSkill,
--   suit = Card.Heart,
--   number = 7,
--   is_damage_card = true,
-- }
-- preLoadCard(likeSlash)
-- extension_card:addCards{
--   likeSlash,
--   likeSlash:clone(Card.Club, 8),
--   likeSlash:clone(Card.Diamond, 9),
--   likeSlash:clone(Card.Spade, 10),
-- }
-- Fk:loadTranslationTable{
--   ["like__slash"] = "杀意",
--   ["like__slash_skill"] = "你手牌每有3张基本伤害牌，伤害+1",
-- 	[":like__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：你手牌每有3张基本伤害牌，伤害+1",
--   ["#like__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点杀伤害",
--   ["#like__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点杀伤害",
-- }
-- --独杀
-- local aloneSlashSkill = fk.CreateActiveSkill{
--   name = "alone__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = function(self, player, card, extra_data)
--     return #player.player_cards[Player.Hand] == 1 and ((extra_data and extra_data.bypass_times) or player.phase ~= Player.Play or
--     table.find(Fk:currentRoom().alive_players, function(p)
--       return self:withinTimesLimit(player, Player.HistoryPhase, card, "slash", p)
--     end))
--   end,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local aloneSlash = fk.CreateBasicCard{
--   name = "alone__slash",
--   skill = aloneSlashSkill,
--   suit = Card.Heart,
--   number = 1,
--   is_damage_card = true,
-- }
-- preLoadCard(aloneSlash)
-- extension_card:addCards{
--   aloneSlash,
--   aloneSlash:clone(Card.Club, 2),
--   aloneSlash:clone(Card.Diamond, 3),
--   aloneSlash:clone(Card.Spade, 4),
-- }
-- Fk:loadTranslationTable{
--   ["alone__slash"] = "独杀",
--   ["alone__slash_skill"] = "当你手牌只剩独杀才可以打出，造成3点伤害",
-- 	[":alone__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：当你手牌只剩独杀才可以打出，造成3点伤害",
--   ["#alone__slash_skill"] = "选择攻击范围内的一名角色，对其造成3点独杀伤害",
--   ["#alone__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成3点独杀伤害",
-- }
-- --抽杀
-- local drawSlashSkill = fk.CreateActiveSkill{
--   name = "draw__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = clone_slash.skill.canUse,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local drawSlash = fk.CreateBasicCard{
--   name = "draw__slash",
--   skill = drawSlashSkill,
--   suit = Card.Spade,
--   number = 8,
--   is_damage_card = true,
-- }
-- preLoadCard(drawSlash)
-- extension_card:addCards{
--   drawSlash,
--   drawSlash:clone(Card.Spade, 10),
--   drawSlash:clone(Card.Club, 8),
--   drawSlash:clone(Card.Club, 10),
-- }
-- Fk:loadTranslationTable{
--   ["draw__slash"] = "抽杀",
--   ["draw__slash_skill"] = "对目标角色造成1点伤害并且摸1张牌",
-- 	[":draw__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成1点伤害并且摸1张牌",
--   ["#draw__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点抽伤伤害",
--   ["#draw__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点抽伤伤害",
-- }
-- --双杀
-- local doubleSlashSkill = fk.CreateActiveSkill{
--   name = "double__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = clone_slash.skill.canUse,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local doubleSlash = fk.CreateBasicCard{
--   name = "double__slash",
--   skill = doubleSlashSkill,
--   suit = Card.Spade,
--   number = 8,
--   is_damage_card = true,
-- }
-- preLoadCard(doubleSlash)
-- extension_card:addCards{
--   doubleSlash,
--   doubleSlash:clone(Card.Spade, 10),
--   doubleSlash:clone(Card.Club, 8),
--   doubleSlash:clone(Card.Club, 10),
-- }
-- Fk:loadTranslationTable{
--   ["double__slash"] = "双杀",
--   ["double__slash_skill"] = "对目标角色造成1点伤害，连续两次",
-- 	[":double__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成1点伤害，连续两次",
--   ["#double__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点双伤伤害",
--   ["#double__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点双伤伤害",
-- }
-- --拔刀杀
-- local bdslashSkill = fk.CreateActiveSkill{
--   name = "bdslash_skill",
--   prompt = "#bdslash_skill",
--   mod_target_filter = Util.TrueFunc,
--   can_use = clone_ex_nihilo.skill.canUse,
--   on_use = clone_ex_nihilo.skill.onUse,
--   on_effect = nullFunc
-- }
-- local bdSlash = fk.CreateBasicCard{
--   name = "bd__slash",
--   suit = Card.Diamond,
--   number = 1,
--   skill = bdslashSkill,
--   is_damage_card = true
-- }
-- preLoadCard(bdSlash)
-- extension_card:addCards({
--   bdSlash,
--   bdSlash:clone(Card.Diamond, 4),
--   bdSlash:clone(Card.Diamond, 8),
--   bdSlash:clone(Card.Diamond, 12),
-- })
-- Fk:loadTranslationTable {
--   ["bd__slash"] = "拔刀杀",
--   [":bd__slash"] = "基本牌牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：对所有敌人造成1点伤害",
--   ["#bdslash_skill"] = "对所有敌人造成1点伤害",
-- }
-- --冲杀
-- local rushSlashSkill = fk.CreateActiveSkill{
--   name = "rush__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = clone_slash.skill.canUse,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local rushSlash = fk.CreateBasicCard{
--   name = "rush__slash",
--   skill = rushSlashSkill,
--   suit = Card.Spade,
--   number = 8,
--   is_damage_card = true,
-- }
-- preLoadCard(rushSlash)
-- extension_card:addCards{
--   rushSlash,
--   rushSlash:clone(Card.Spade, 10),
--   rushSlash:clone(Card.Club, 8),
--   rushSlash:clone(Card.Club, 10),
-- }
-- Fk:loadTranslationTable{
--   ["rush__slash"] = "冲杀",
--   ["rush__slash_skill"] = "对目标角色造成格挡值伤害",
-- 	[":rush__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成格挡值伤害",
--   ["#rush__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点冲杀伤害",
--   ["#rush__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点冲杀伤害",
-- }
-- --备杀
-- local U = require "packages/utility/utility"
-- local drawdisSlashSkill = fk.CreateActiveSkill{
--   name = "drawdis__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = clone_slash.skill.canUse,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local drawdisSlash = fk.CreateBasicCard{
--   name = "drawdis__slash",
--   skill = drawdisSlashSkill,
--   suit = Card.Spade,
--   number = 8,
--   is_damage_card = true,
-- }
-- preLoadCard(drawdisSlash)
-- extension_card:addCards{
--   drawdisSlash,
--   drawdisSlash:clone(Card.Spade, 10),
--   drawdisSlash:clone(Card.Club, 8),
--   drawdisSlash:clone(Card.Club, 10),
-- }
-- Fk:loadTranslationTable{
--   ["drawdis__slash"] = "备杀",
--   ["drawdis__slash_skill"] = "对目标角色造成1点伤害并从弃牌堆获得1张牌",
-- 	[":drawdis__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成1点伤害并从弃牌堆获得1张牌",
--   ["#drawdis__slash_skill"] = "选择攻击范围内的一名角色，对其造成1点备杀伤害",
--   ["#drawdis__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成1点备杀伤害",
--   ["selcardbydiscs"] = "弃牌堆选卡",
--   ["fhjd_selcard"] = "选卡"
-- }
-- --狂杀
-- local crazySlashSkill = fk.CreateActiveSkill{
--   name = "crazy__slash_skill",
--   prompt = clone_slash.skill.prompt,
--   max_phase_use_time = 1,
--   target_num = 1,
--   can_use = clone_slash.skill.canUse,
--   mod_target_filter = clone_slash.skill.modTargetFilter,
--   target_filter = clone_slash.skill.targetFilter,
--   on_effect = nullFunc
-- }
-- local crazySlash = fk.CreateBasicCard{
--   name = "crazy__slash",
--   skill = crazySlashSkill,
--   suit = Card.Spade,
--   number = 8,
--   is_damage_card = true,
-- }
-- preLoadCard(crazySlash)
-- extension_card:addCards{
--   crazySlash,
-- }
-- Fk:loadTranslationTable{
--   ["crazy__slash"] = "狂杀",
--   ["crazy__slash_skill"] = "对目标角色造成3点伤害并在抽牌堆放一张【受伤】卡牌",
-- 	[":crazy__slash"] = "基本牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：攻击范围内的一名角色<br /><b>效果</b>：对目标角色造成3点伤害并在抽牌堆放一张【受伤】卡牌",
--   ["#crazy__slash_skill"] = "选择攻击范围内的一名角色，对其造成3点狂杀伤害",
--   ["#crazy__slash_skill_multi"] = "选择攻击范围内的至多%arg名角色，对这些角色各造成3点狂杀伤害",
-- }
-- --技能牌
-- --燃烧
-- local burnSkill = fk.CreateActiveSkill{
--   name = "burn_skill",
--   prompt = "#burn_skill",
--   mod_target_filter = Util.TrueFunc,
--   can_use = function(self, player, card)
--     return not player:isProhibited(player, card) and #player.player_cards[Player.Hand] ~= 1
--   end,
--   on_use = clone_ex_nihilo.skill.onUse,
--   on_effect = nullFunc
-- }
-- local burnHot = fk.CreateTrickCard{
--   name = "burnHot",
--   suit = Card.Diamond,
--   number = 1,
--   skill = burnSkill,
-- }
-- preLoadCard(burnHot)
-- extension_card:addCards({
--   burnHot,
--   burnHot:clone(Card.Diamond, 4),
-- })
-- Fk:loadTranslationTable {
--   ["burnHot"] = "燃烧",
--   [":burnHot"] = "锦囊牌牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：选择1张牌消耗，摸2张牌",
--   ["#burn_skill"] = "选择1张牌消耗，摸2张牌",
-- }
-- --武装
-- local equipselfSkill = fk.CreateActiveSkill{
--   name = "equipself_skill",
--   prompt = "#equipself_skill",
--   mod_target_filter = Util.TrueFunc,
--   can_use = function(self, player, card)
--     return not player:isProhibited(player, card) and #player.player_cards[Player.Hand] ~= 1
--   end,
--   on_use = clone_ex_nihilo.skill.onUse,
--   on_effect = nullFunc
-- }
-- local equipSelf = fk.CreateTrickCard{
--   name = "equipSelf",
--   suit = Card.Diamond,
--   number = 1,
--   skill = equipselfSkill,
-- }
-- preLoadCard(equipSelf)
-- extension_card:addCards({
--   equipSelf,
--   equipSelf:clone(Card.Diamond, 4),
-- })
-- Fk:loadTranslationTable {
--   ["equipSelf"] = "武装",
--   [":equipSelf"] = "锦囊牌牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：选择1张牌升级仅限本次战斗（升级此卡则是改为手牌）",
--   ["#equipself_skill"] = "选择1张牌升级仅限本次战斗（升级此卡则是改为手牌）",
-- }
-- --逞强
-- local bravadoSkill = fk.CreateActiveSkill{
--   name = "bravado_skill",
--   prompt = "#bravado_skill",
--   mod_target_filter = Util.TrueFunc,
--   can_use = clone_ex_nihilo.skill.canUse,
--   on_use = clone_ex_nihilo.skill.onUse,
--   on_effect = nullFunc
-- }
-- local bravadoskill = fk.CreateTriggerSkill{
--   name = "bravadoskill",
--   anim_type = "control",
--   frequency = Skill.Compulsory,
--   events = {fk.TurnEnd},
--   can_trigger = function (self, event, target, player, data)
--     if not player:hasSkill(self.name) then return end
--     return player == target
--   end,
--   on_use = function(self, event, target, player, data)
--     local room = player.room
--     if room.logic.class.name == Fhjd_Mode then
--       local mark = player:getMark("@hfjd_power")
--       room:setPlayerMark(player,"@hfjd_power",mark-(1+fhjdExtraAdd(room,effect.card,"@up_power")))
--       if mark - 1 <= 0 then
--         room:handleAddLoseSkills(player, "-bravadoskill", nil, false)
--       end
--     end
--   end,
-- }
-- Fk:addSkill(bravadoskill)
-- local bravaDo = fk.CreateTrickCard{
--   name = "bravaDo",
--   suit = Card.Diamond,
--   number = 1,
--   skill = bravadoSkill,
-- }
-- preLoadCard(bravaDo)
-- extension_card:addCards({
--   bravaDo,
--   bravaDo:clone(Card.Diamond, 4),
-- })
-- Fk:loadTranslationTable {
--   ["bravaDo"] = "逞强",
--   ["bravadoskill"] = "逞强",
--   [":bravaDo"] = "锦囊牌牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：获得1点力量，结束阶段失去1点力量",
--   ["#bravado_skill"] = "获得1点力量，结束阶段失去1点力量",
-- }
-- --破灭
-- local fallthroughSkill = fk.CreateActiveSkill{
--   name = "fallthrough_skill",
--   prompt = "#fallthrough_skill",
--   mod_target_filter = Util.TrueFunc,
--   can_use = clone_ex_nihilo.skill.canUse,
--   on_use = clone_ex_nihilo.skill.onUse,
--   on_effect = nullFunc
-- }
-- local fallThrough = fk.CreateTrickCard{
--   name = "fallThrough",
--   suit = Card.Diamond,
--   number = 1,
--   skill = fallthroughSkill,
-- }
-- preLoadCard(fallThrough)
-- extension_card:addCards({
--   fallThrough,
--   fallThrough:clone(Card.Diamond, 4),
-- })
-- Fk:loadTranslationTable {
--   ["fallThrough"] = "破灭",
--   [":fallThrough"] = "锦囊牌牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：打出抽牌堆1张牌，将其消耗",
--   ["#fallthrough_skill"] = "打出抽牌堆1张牌，将其消耗",
--   ["#fallthrough_skill_choose"] = "选择其他一名角色"
-- }
-- --无畏
-- local fearlessSkill = fk.CreateActiveSkill{
--   name = "fearless_skill",
--   prompt = "#fearless_skill",
--   mod_target_filter = Util.TrueFunc,
--   can_use = clone_ex_nihilo.skill.canUse,
--   on_use = clone_ex_nihilo.skill.onUse,
--   on_effect = nullFunc
-- }
-- local fearLess = fk.CreateTrickCard{
--   name = "fearLess",
--   suit = Card.Diamond,
--   number = 1,
--   skill = fearlessSkill,
-- }
-- preLoadCard(fearLess)
-- extension_card:addCards({
--   fearLess,
--   fearLess:clone(Card.Diamond, 4),
-- })
-- Fk:loadTranslationTable {
--   ["fearLess"] = "无畏",
--   [":fearLess"] = "锦囊牌牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：摸1张牌获得1护甲",
--   ["#fearless_skill"] = "摸1张牌获得1护甲",
-- }
-- --坚毅
-- local unwaverSkill = fk.CreateActiveSkill{
--   name = "unwaver_skill",
--   prompt = "#unwaver_skill",
--   mod_target_filter = Util.TrueFunc,
--   can_use = function(self, player, card)
--     return not player:isProhibited(player, card) and #player.player_cards[Player.Hand] ~= 1
--   end,
--   on_use = clone_ex_nihilo.skill.onUse,
--   on_effect = nullFunc
-- }
-- local unWaver = fk.CreateTrickCard{
--   name = "unWaver",
--   suit = Card.Diamond,
--   number = 1,
--   skill = unwaverSkill,
-- }
-- preLoadCard(unWaver)
-- extension_card:addCards({
--   unWaver,
--   unWaver:clone(Card.Diamond, 4),
-- })
-- Fk:loadTranslationTable {
--   ["unWaver"] = "坚毅",
--   [":unWaver"] = "锦囊牌牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：消耗1张牌获得1护甲",
--   ["#unwaver_skill"] = "消耗1张牌获得1护甲",
-- }
-- --双持
-- local cloneDoubleSkill = fk.CreateActiveSkill{
--   name = "clonedouble_skill",
--   prompt = "#clonedouble_skill",
--   mod_target_filter = Util.TrueFunc,
--   can_use = clone_ex_nihilo.skill.canUse,
--   on_use = clone_ex_nihilo.skill.onUse,
--   on_effect = nullFunc
-- }
-- local cloneDouble = fk.CreateTrickCard{
--   name = "cloneDouble",
--   suit = Card.Diamond,
--   number = 1,
--   skill = cloneDoubleSkill,
-- }
-- preLoadCard(cloneDouble)
-- extension_card:addCards({
--   cloneDouble,
--   cloneDouble:clone(Card.Diamond, 4),
-- })
-- Fk:loadTranslationTable {
--   ["cloneDouble"] = "双持",
--   [":cloneDouble"] = "锦囊牌牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：自己<br /><b>效果</b>：将手牌的伤害牌或能力牌复制1张",
--   ["#clonedouble_skill"] = "将手牌的伤害牌或能力牌复制1张",
-- }
-- --诅咒牌
-- --受伤
-- local hurtStatusSkill = fk.CreateActiveSkill{
--   name = "hurtstatus_skill",
--   prompt = "#hurtstatus_skill",
--   mod_target_filter = Util.TrueFunc,
--   can_use = function(self, player, card)
--     return false
--   end,
--   on_use = function(self, room, cardUseEvent)
--   end,
--   on_effect = function(self, room, effect)
--   end
-- }
-- local hurtStatus = fk.CreateBasicCard{
--   name = "hurtstatus",
--   suit = Card.Spade,
--   number = 1,
--   skill = hurtStatusSkill,
-- }
-- preLoadCard(hurtStatus)
-- extension_card:addCards({
--   hurtStatus,
--   -- hurtStatus:clone(Card.Spade, 4),
--   -- hurtStatus:clone(Card.Spade, 8),
--   -- hurtStatus:clone(Card.Spade, 12),
-- })
-- Fk:loadTranslationTable {
--   ["hurtstatus"] = "受伤",
--   [":hurtstatus"] = "状态牌<br /><b>时机</b>：<br /><b>目标</b>：<br /><b>效果</b>：不能打出此牌",
--   ["#hurtstatus_skill"] = "不能打出此牌",
-- }
----------------------定义卡组---------------------------
Fk:addGameMode(require "packages/wdtx/WDTX_mode")
return {extension,extension_card}